Solved

Button menu icon.

Posted on 2000-04-27
20
728 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

820 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