[RESOLVED] Help With SP6 Toolbar
Hello,
Ive created a floating tool bar with a single drop down button and some sub items. How do I go about adding a bitmap to each of the sub items, as well as a checked field. Im guessing I need to use the windows APIs?
Im having a bit of a hard time getting started with it, does any one have any examples on it?
Re: Help With SP6 Toolbar
Quote:
Originally Posted by LukeD4567
Hello,
Ive created a floating tool bar with a single drop down button and some sub items.
What control(s) did you use to do that?
Re: Help With SP6 Toolbar
I think he has used Windows Common Controls Toolbar (SP6).
The button menu is a 'normal' menu. When you click the buttongroup, the oolbar sends a WM_INITMENUPOPUP message.
If you subclass the toolbar, you can get hwnd of the popup menu from WM_INITMENUPOPUP message. Then you can modify the menuitems as you like.
here (post#18 onwards) are examples of similar code for external applications. Those codes uses 'Hooking', but as the toolbar is in your own application, it will be a LOT easier in your case. You can do what you want by using 'normal subclassing'.
Re: Help With SP6 Toolbar
Thanks, but when I try to use either GetSubMenu(Toolbar1.hwnd, 0), or getmenu(Toolbar1.hwnd), I get 0. Am I supposed to be using a different API call? Or am I passing the wrong argument?
Re: Help With SP6 Toolbar
Quote:
Originally Posted by iPrank
The button menu is a 'normal' menu. When you click the buttongroup, the oolbar sends a WM_INITMENUPOPUP message...
Perhaps, but in reality since it's built into a dll its behavior is completely different despite the visual similarities.
Re: Help With SP6 Toolbar
DO NOT use ToolBar1.hWnd. If you get the toolbar's hWnd by FindWindow, you'll be able to subclass it correctly.
I've success fully added bitmap to button menus by subclassing this hWnd. Will try SetMenuItemInfo when I return.
vb Code:
Private Sub Form_Load()
Dim hToolbar20WndClass As Long
Dim hMsVbLibToolBar As Long ' The "correct" hWnd of the toolbar
hToolbar20WndClass = FindWindowEx(Me.hwnd, 0&, "Toolbar20WndClass", vbNullString)
hMsVbLibToolBar = FindWindowEx(hToolbar20WndClass, 0&, "msvb_lib_toolbar", vbNullString)
' Now Subclass "hMsVbLibToolBar" and listen for WM_INITMENUPOPUP
End Sub
1 Attachment(s)
Re: Help With SP6 Toolbar
Here is a sample code that adds bitmaps in a ButtonMenu.
For the CheckedMenu, I couldn't manage to find any way to successfully set MF_CHECKED.
So, I'm using a boolean variable and a checkmark bitmap to track checked status.
Re: Help With SP6 Toolbar
Thanks, thats exactly what I was looking for, appreciate that.