Clif
asked on
Toolbar Button Menus
I'm attemping to create something similar to the "Fill Color" button in Excel.
For those who don't know, the "Fill Color" button has an image of a paint can with a bar in the currently selected fill color. Clicking on the drop-down arrow shows a pallet which allows you to select the fill color.
My problem is in setting the image of the button to the correct image. I know I can fill up the image list control which is attached to the tool bar, but I'd rather have a separate image list with just the fill color icons, which I then assign to the "Fill Color" button.
I can't get the button's image to change, though.
Here is the code I'm trying to use:
Private Sub tbrMain_ButtonMenuClick(By Val ButtonMenu As MSComctlLib.ButtonMenu)
imlMain.ListImages(16).Dra w imlFillColor.ListImages(Bu ttonMenu.I ndex).Pict ure, , , imlNormal
g_sFillColor = ButtonMenu.Key
End Sub
Basically, why doesn't this work, and how can I make it work?
For those who don't know, the "Fill Color" button has an image of a paint can with a bar in the currently selected fill color. Clicking on the drop-down arrow shows a pallet which allows you to select the fill color.
My problem is in setting the image of the button to the correct image. I know I can fill up the image list control which is attached to the tool bar, but I'd rather have a separate image list with just the fill color icons, which I then assign to the "Fill Color" button.
I can't get the button's image to change, though.
Here is the code I'm trying to use:
Private Sub tbrMain_ButtonMenuClick(By
imlMain.ListImages(16).Dra
g_sFillColor = ButtonMenu.Key
End Sub
Basically, why doesn't this work, and how can I make it work?
ASKER
So, you're saying that it should be:
imlFillColor.ListImages(Bu ttonMenu.I ndex).Draw imlMain.ListImages(16).Pic ture, , , imlNormal
Unfortunately the "Picture" object doesn't have a hDC property (not exposed, at any rate).
imlFillColor.ListImages(Bu
Unfortunately the "Picture" object doesn't have a hDC property (not exposed, at any rate).
you can get dc with GetDc API, then
dim hdcpic as long
hdcPic=GetDC(picture1.hwnd )
dim hdcpic as long
hdcPic=GetDC(picture1.hwnd
ASKER
Unfortunately the Picture object of the ImageList control doesn't have an hWnd property either.
Sorry, very sorry. I don't know what i was thinking... I must read question before post anything... :D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry it took so long to grade, but I lost this. :)
At any rate, I went with multiple images in the image list.
At any rate, I went with multiple images in the image list.
The Where is a device context of the item you want to draw on. Usually Form1.hdc or similar. Does the ButtonMenu have an .hdc property?