Results 1 to 7 of 7

Thread: Form Menu's

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217
    Alright I can give bitmaps to a menu using the api. But I can only get the first menu on the form using getmenu(me.hwnd). How can I get the other menus and add bitmaps to their submenus?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Getmenu returns the handle of the first menu (the menu bar ).
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    So

    So how can I get the other menus, as in say the 2nd and 3rd on my form
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    First, get the menu handle of the menu bar. Then you can use the GetSubMenu api function, to get the handles of the menus (like File). Its syntax is simple.
    Code:
    Declare Function GetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    hMenu = The handle of the menu bar
    nPos = Which menu, the first = 0, the 2nd = 1 and so on.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    hmm

    Wouldnt that just get file's submenus? I want to get the hwnd of say..edit
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    I assume that Edit is the 2nd menu. To get the handle of the edit menu:
    Code:
    Dim Handle As Long
    Handle = GetSubMenu(GetMenu(Me.hwnd), 1) '1, because counting starts with 0:rolleyes:
    To get the first item in the edit menu, use the GetMenuItemID api function. Sorry, I couldn't find info on it on the internet. So, just get the declaration from Win32api.txt. It takes two arguments.
    • hMenu As Long, it's the id of the Edit/File/etc. menu that you just got.
    • nPos As Long, the position of the item in the menu. Counting also starts here with 0.

    Sorry that I didn't include the declarations for the api functions in this post. I don't have vb on this computer.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Talking

    Thanks, I have the API Toolkit from allapi.net so the declares are all in there. Their example was only for the first menu though. Thanks
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

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