Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

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(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
    imlMain.ListImages(16).Draw imlFillColor.ListImages(ButtonMenu.Index).Picture, , , imlNormal
    g_sFillColor = ButtonMenu.Key
End Sub

Basically, why doesn't this work, and how can I make it work?
0
Clif
Asked:
Clif
  • 3
  • 2
  • 2
1 Solution
 
ventondCommented:
The first parameter of the .Draw method is WHERE to draw, not WHAT to draw. The What is handeled by .ListImages(16).

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?

0
 
ClifAuthor Commented:
So, you're saying that it should be:

    imlFillColor.ListImages(ButtonMenu.Index).Draw imlMain.ListImages(16).Picture, , , imlNormal

Unfortunately the "Picture" object doesn't have a hDC property (not exposed, at any rate).
0
 
Richie_SimonettiIT OperationsCommented:
you can get dc with GetDc API, then
dim hdcpic as long
hdcPic=GetDC(picture1.hwnd)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ClifAuthor Commented:
Unfortunately the Picture object of the ImageList control doesn't have an hWnd property either.
0
 
Richie_SimonettiIT OperationsCommented:
Sorry, very sorry. I don't know what i was thinking... I must read question before post anything... :D
0
 
ventondCommented:
You can't draw onto an image list control because the image list control has no visible component.

I played with button menus and what I think you are going to do is something like:

Toolbar.Buttons(button.index).image = [index of colored pic]



I say this because you aren't drawing the picture. You are trying to tell the toolbar what picture to draw. The toolbar looks in a List Image control for the pictures to show. If you want to draw the color you will have to catch every repaint/refresh event to redraw everytime. Special note, ALL of the images that you want the toolbar to use must be in one List image control.

I am not at a computer that I can test this at the moment so I hope the Image property is available in the collection.

0
 
ClifAuthor Commented:
Sorry it took so long to grade, but I lost this.  :)

At any rate, I went with multiple images in the image list.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now