Results 1 to 8 of 8

Thread: [RESOLVED] Help With SP6 Toolbar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    18

    Resolved [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?

  2. #2

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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'.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    18

    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?

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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:
    1. Private Sub Form_Load()
    2.  
    3.     Dim hToolbar20WndClass As Long
    4.     Dim hMsVbLibToolBar As Long ' The "correct" hWnd of the toolbar
    5.     hToolbar20WndClass = FindWindowEx(Me.hwnd, 0&, "Toolbar20WndClass", vbNullString)
    6.     hMsVbLibToolBar = FindWindowEx(hToolbar20WndClass, 0&, "msvb_lib_toolbar", vbNullString)
    7.    
    8.    ' Now Subclass "hMsVbLibToolBar" and listen for WM_INITMENUPOPUP
    9.  
    10. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    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.

    Attached Files Attached Files
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    18

    Re: Help With SP6 Toolbar

    Thanks, thats exactly what I was looking for, appreciate that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width