Solved

Button menu icon.

Posted on 2000-04-27
20
710 Views
Last Modified: 2008-03-06
Hello:
    How to add icons in the button menus, please? I can't find any place to add.
0
Comment
Question by:prefix
  • 8
  • 6
  • 5
  • +1
20 Comments
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
Add an ImageList control to place the pictures in. Then assign the ImageList to the ToolBar either in design time or in runtime.

Toolbar1.ImageList = ImageList1

Then assign the Image property of each button to an ImageList picture index, either in design time or runtime like this:

Toolbar1.Buttons(1).Image = 1 'First image in list

0
 
LVL 3

Expert Comment

by:Elmo_
Comment Utility
You need to have included the Common controls and added a Toolbar control to your Form.  You also need an Image list if you want to insert pictures into the toolbar buttons

When you add the image list in, right click on the inmage list control and this will enable you to get pictures and store them into the inmage list control - Best plave is in the Vb-Graphics folder.

Then right click the toolbar and goto the properties and then apply the image list to the toolbar and then goto each button individually and assign them a picture based on the order you inserted your pictures.

Hope this helps!
0
 
LVL 1

Author Comment

by:prefix
Comment Utility
Thanks, but the problem is I'm using a button menu, the menu pops up while I click the button. I want to add icons on the popped up menu not the button.
(I'm using VB6)
0
 
LVL 1

Author Comment

by:prefix
Comment Utility
BTW£ºThe menu is owned by VB6.
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
See:

"Adding Bitmaps to Menus"
http://www.vb-world.net/controls/tip64.html
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
More of the same:

"Adding a bimap to a menu entry"
http://www.spnc.demon.co.uk/vb/vbmnicon.htm
0
 

Expert Comment

by:IsaacRU
Comment Utility
Check out this control called WinMenu it allows you do add graphics to all menus you can download it at:

http://download.cnet.com/downloads/0-14480-100-905109.html?tag=st.dl.10009_103_1.lst.td
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
It's all doable in code, no need to add yet another OCX!
0
 

Expert Comment

by:IsaacRU
Comment Utility
It may be doable in code but ocx controls can simplify the process.
0
 
LVL 1

Author Comment

by:prefix
Comment Utility
Oh, no, it's not this problem.
The problem just: I add a Toolbar in VB6(the new one, has a Office97 style, only in VB6), then I add many images in a imagelist, now I can add buttons in the toolbar, and the toolbar property page-buttons page shows, there's a button "Insert ButtonMenu" on this page, so I clicked it, added two buttonmenus in my button. My (toolbar) button has an icon, when I click on this button, it commonly runs, and there's an arrow on the right of this button, when I click the arrow,a menu pops up, whows two options--They're the buttonmenus I added. but they don't have icons.
This button style looks like the "Add Form" button in VB6, clicking on the button runs the default one, clicking on the arrow pops up a menu and have many options in.
Can understand? Hope you can.
Hope you can help me.
Thank you.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 32

Expert Comment

by:Erick37
Comment Utility
From
http://msdn.microsoft.com/library/periodic/period98/vbpj1098.htm

"VB6 also lets you use the new tbrDropDown style to attach drop-down menus to toolbar buttons. You create such menus at design-time in the Toolbar property page, at runtime when the form loads, or even when the user clicks the button. ... One drawback of the Toolbar control is that it doesn't offer support for check marks or secondary submenus."

I have tried to obtain the menu handle by using
GetMenu(Toolbar1.hwnd)
but it returns 0.

Without a way to get the menu handle, there is no way to add bitmaps.
0
 

Expert Comment

by:IsaacRU
Comment Utility
Wait a sec let me get this right. You have a toolbar right? and you are using the PopMenu function to show a menu when the button is clicked?
0
 

Expert Comment

by:IsaacRU
Comment Utility
Sorry I did not understand what your problem is. There is a way to show bitmaps. Instead of adding the menus in the custom toolbar properties or at runtime. Create a button in the toolbar, change its style to 5- dropdown, and then when the dropown button is click use the PopupMenu function to reference to a standard menu object. Now you should be able to add icons to your menu the way Erick37 said.
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
VB6 ToolBar has a new feature which allows a dropdown menu (IE style).  Limitations are: no checkmarks, single level only.

It may be possible to display a custom Popup Menu in the ButtonMenuClick event.

I will try it and see...
0
 

Expert Comment

by:IsaacRU
Comment Utility
Thats what i was talking about in my lat comment. It will work.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 30 total points
Comment Utility
Yes, with a little work it can be done.  Here is a little example using one button and one popup menu to replace the button's dropdown menu.  since a popupmenu is used, bitmaps can be added to them per the articles above.

Private Sub Form_Load()
    Toolbar1.Buttons(1).ButtonMenus.Add 1, , "Dummy"
End Sub

Private Sub Toolbar1_ButtonDropDown(ByVal Button As MSComctlLib.Button)
    PopupMenu mnuPopup, , Button.Left, Button.Height
    Button.ButtonMenus.Add 1, , "Dummy"
    Button.ButtonMenus(1).Visible = False
End Sub

Private Sub Toolbar1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Toolbar1.Buttons(Button).ButtonMenus.Remove 1
End Sub
0
 
LVL 1

Author Comment

by:prefix
Comment Utility
Sorry, I make you wait so much.
Everybody:
    Thank you for your help very much. But is there no way to add icons to this buttonmenu? Using a popupmenu it's really work, but...I want another way and "really add icons to a buttonmenu".
.......is it possible? ......Thank you again.....
0
 
LVL 1

Author Comment

by:prefix
Comment Utility
Thank you very much.
Didn't you see my last comment?
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
I know of no way to add pictures to the Button menu of a ToolbarButton.  The menu handle is not exposed, so it can't be modified in code.

If I run across some more info regarding this, I will post a comment to let you know.
0
 
LVL 1

Author Comment

by:prefix
Comment Utility
Thank you, Erick37.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 61
VB 6.0 printer how to align 6 49
MsgBox 2 36
Spell Check in VB6 13 42
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

17 Experts available now in Live!

Get 1:1 Help Now