Solved

Button menu icon.

Posted on 2000-04-27
20
715 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
ID: 2755205
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_
ID: 2755245
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
ID: 2755261
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
ID: 2755272
BTW£ºThe menu is owned by VB6.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2755783
See:

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

Expert Comment

by:Erick37
ID: 2755815
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
ID: 2756129
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
ID: 2756759
It's all doable in code, no need to add yet another OCX!
0
 

Expert Comment

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

Author Comment

by:prefix
ID: 2757841
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:Erick37
ID: 2757948
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
ID: 2760584
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
ID: 2760639
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
ID: 2760645
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
ID: 2760663
Thats what i was talking about in my lat comment. It will work.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 30 total points
ID: 2761161
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
ID: 2783835
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
ID: 2796156
Thank you very much.
Didn't you see my last comment?
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2796197
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
ID: 2800009
Thank you, Erick37.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

932 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

10 Experts available now in Live!

Get 1:1 Help Now