Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup Menu Handle

Status
Not open for further replies.

godeny

Programmer
Joined
Jul 31, 2000
Messages
2
Location
HU
How can I get the Windows Handle of a Popup Menu ? I want to change the properties of some menu items (to cut the menu into two or more columns). Following the examples found elsewhere it works fine with a "static" menu, the menu of a form - I can ask Windows for the menu handle of a window. But I have no idea how to get from VB the handle of a popup menu.
 
is this a popup menu in vb or one of the windows system ones
 
It is in VB. I declare a menu in the VB form, but set it invisible in the form's Load event.<br>
 
Here is some code which I have used to add Bitmaps onto menus, this included popups <br><br><br>Module Stuff<br><br>Option Explicit<br><br>Declare Function GetMenu Lib &quot;user32&quot; _<br>(ByVal hwnd As Long) As Long<br><br>Declare Function GetSubMenu Lib &quot;user32&quot; _<br>(ByVal hMenu As Long, ByVal nPos As Long) As Long<br><br>Declare Function GetMenuItemID Lib &quot;user32&quot; _<br>(ByVal hMenu As Long, ByVal nPos As Long) As Long<br><br>Type MENUITEMINFO<br>&nbsp;&nbsp;&nbsp;&nbsp;cbSize As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;fMask As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;fType As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;fState As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;wID As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;hSubMenu As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;hbmpChecked As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;hbmpUnchecked As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;dwItemData As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;dwTypeData As String<br>&nbsp;&nbsp;&nbsp;&nbsp;cch As Long<br>End Type<br><br>Declare Function GetMenuItemCount Lib &quot;user32&quot; _<br>(ByVal hMenu As Long) As Long<br><br>Declare Function GetMenuItemInfo Lib &quot;user32&quot; _<br>Alias &quot;GetMenuItemInfoA&quot; (ByVal hMenu As Long, _<br>ByVal un As Long, ByVal b As Boolean, _<br>lpMenuItemInfo As MENUITEMINFO) As Boolean<br><br>Public Const MIIM_ID = &H2<br>Public Const MIIM_TYPE = &H10<br>Public Const MFT_STRING = &H0&<br><br><br><br><br>Form Stuff<br><br>Dim hMenu&, hSubMenu&, hID&, ExtraSubMenu&<br><br>'Get the menuhandle of your app<br>hMenu& = GetMenu(Me.hwnd)<br><br>'file menu<br>'Get the handle of the first submenu<br>hSubMenu& = GetSubMenu(hMenu&, 0)<br><br><br>Menus are 0 based therefore first menu = 0 second = 1 etc <br>so if you know the order that your menus are in you can get the handle for each of them<br><br><br>Hope that this is what your after<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top