Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15908

Adding menus to a menubar

$
0
0
When you add menus to a menubar using code (not the Menu Editor) how then do you add functionality to the added menus. Assume my Form already has three top level menu items each with a sub menu and each has a Sub that performs the functionalities for the menu items. The following code will append a new top level menu item at the end of the menubar and a sub menu. How do I add functionality to that newly appended menu

Code:

Private Sub cmdAddNewMenu_Click()
 Dim MII As MENUITEMINFOW
 
 m_hMenu = GetMenu(AppHwnd)

 If m_hMenu Then
  AppendMenuW m_hMenu, MF_STRING, IDM_TOP_LEVEL_0, StrPtr("My Added Menu")

  SetMenu AppHwnd, m_hMenu
  DrawMenuBar AppHwnd
 End If
   
 GetSubMenu m_hMenu, 3&

 MII.cbSize = LenB(MII)
 MII.fMask = MIIM_SUBMENU
 MII.hSubMenu = CreatePopupMenu

 If MII.hSubMenu Then
  AppendMenuW MII.hSubMenu, MF_STRING, IDM_SUB_MENU_0, StrPtr("My Added Sub Menu")
     
  SetMenuItemInfoW m_hMenu, IDM_TOP_LEVEL_0, False, MII
 
  DrawMenuBar AppHwnd
 End If
End Sub


Viewing all articles
Browse latest Browse all 15908

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>