Results 1 to 7 of 7

Thread: Need help on color pallete..

  1. #1

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    Post

    Hi there!

    How to show the color pallete in my app.
    like the one that is shown in MS-Word (Font color icon)?i

    Thanx in Advance.
    Jebs.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You can either Draw some Colored Boxes ona Toolbox Form and use the Point() Method to get the Color of the Pixel under the Mouse when Clicked, or use the CommonDialogbox, ie.
    Code:
    Private Sub Command1_Click()
        With CommonDialog1
            'Use this Flag to also Show the Custom Color Palette
            .Flags = cdlCCFullOpen
            .ShowColor
            BackColor = .Color
        End With
    End Sub

  3. #3
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    As for the icon, just find an icon on the net, and put it on a toolbar button, then call the common dialog as aaron had said when that button is clicked. You could also get the icon by doing a screen grab on the app that has the icon you want (CTRL+PrintScreen) and crop out the rest of the screen.

    You may also want to check out this example:

    http://micah.carrick.com/archives/ColorPick.zip

    which demonstrates how you can add the 16 colors from the standar pallete to an image combo (using all code rather than 16 bitmaps).

  4. #4

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    Post

    Sorry! 'cos I was not clear with my question. I will tell u what I want. When I click the Font color icon in MS-Word, a color pallete appears beneath that icon. How to show that kind of color box? Thanks in advance.
    Jebs.

  5. #5
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Oh, Like a menu that pops down under the button with the colors?

    i had an app that did that once but i no longer have the code, and I'm a bit tired at them moment. I'll tell ya how i did it though.

    I used the GetCursorPosition to show and move a form to that button. (I could have just done frmMain.left + button.left though i imagine) and this form had "" for a caption, BorderStyle=FixedDialog and ControlBox = False so that the form didn't have a titlebar.

    Then, I made this form have an array of 16 pictureboxes and labels which were highlighted (BackColor = vbHighlight, ForeColor = vbHighlightText) in the mouseMove event and set the color of my RTF box to the color th3e mouse was over in the mouse click event.


    Sorry I can't be more specific at the moment ... hope that helps a little.
    Micah Carrick
    Visual Basic 6 SP5
    Visual Basic.NET
    Quixotix Software
    [email protected]
    Download QCM 1.0 - Intelligent ActiveX Control Management

  6. #6

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    Post

    Thanks Mr. MicahCarrick!
    I have got the idea. In some applications, when we move the mouse over a particular color, that part (color) gets bulged. Is it possible with this (In this case, the picture box)?

    Jebs.
    ICQ # 57900212



  7. #7
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Yes, that's exactly what I did, well, I'm not sure exactly what you mean by "bulge", but you can do anything really. What I did is have a picturebox which was indented when the mouse was over. You could also create a function that will make the picturebox appear to bevel out (like a toolbar button does when the mouse is over) by using the Line Function with the vb3DHighlight and vb3DShadow color constants.) Since I had an array of picture box's, i had code that looked something like this


    Private Sub picColor_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

    'Since when the backstyle is changed, it changes the
    'color, by storing the backcolor in a variable, we
    'can restore it afterward.

    Dim lOrigColor as Long
    Dim I as Long 'Loop Counter


    'First, ensure any previously "highlighted" boxes
    'get returned to normal.

    For I = 0 to picColor.Count - 1 Step 1
    lOrigColor = picColor(I).BackColor
    picColor(i).Appearance = 0 'Flatten box
    picColor(i).BackColor = lOrigColor 'Restore color
    Next

    'Now, bevel the currently "Hovered" color

    lOrigColor = picColor(Index).Backcolor
    picColor(Index).Appearence = 1 '3D
    picColor(Index).BackColor = lOrigColor

    'Then, if you have labels next to each color, just
    'make sure they have the same index as their picturebox
    'Then, put all the preceding code into it's own Sub and
    'add the code to highlight the labels. Then, in both the
    'label's and picColor's mouseMove events call that sub,
    'passing the index.

    End Sub

    End Sub
    Micah Carrick
    Visual Basic 6 SP5
    Visual Basic.NET
    Quixotix Software
    [email protected]
    Download QCM 1.0 - Intelligent ActiveX Control Management

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width