Solved

Toolbar Button Menus

Posted on 2002-07-25
7
221 Views
Last Modified: 2010-05-02
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
Comment
Question by:Clif
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:ventond
Comment Utility
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
 
LVL 10

Author Comment

by:Clif
Comment Utility
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
you can get dc with GetDc API, then
dim hdcpic as long
hdcPic=GetDC(picture1.hwnd)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Author Comment

by:Clif
Comment Utility
Unfortunately the Picture object of the ImageList control doesn't have an hWnd property either.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Sorry, very sorry. I don't know what i was thinking... I must read question before post anything... :D
0
 
LVL 2

Accepted Solution

by:
ventond earned 100 total points
Comment Utility
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
 
LVL 10

Author Comment

by:Clif
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now