Home » Forms » How to add Split in Menu
How to add Split in Menu
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 'Forms - How to add Split in Menu Option Explicit 'Add menu to your form and add 4 Sub Menus to that. Public Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long Public Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, _ ByVal un As Long, ByVal b As Boolean, lpmii As MENUITEMINFO) As Long Public Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, _ ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long Public Const MIIM_STATE = &H1 Public Const MIIM_ID = &H2 Public Const MIIM_SUBMENU = &H4 Public Const MIIM_CHECKMARKS = &H8 Public Const MIIM_TYPE = &H10 Public Const MIIM_DATA = &H20 Public Const MFT_RADIOCHECK = &H200& Public Const MFT_STRING = &H0& Public Const RGB_STARTNEWCOLUMNWITHVERTBAR = &H20& Public Const RGB_STARTNEWCOLUMN = &H40& Public Const RGB_EMPTY = &H100& Public Const RGB_VERTICALBARBREAK = &H160& Public Const RGB_SEPARATOR = &H800& Private Sub Form_Load() Dim r As Long, hSubMenu As Long, mnuItemCount As Long Dim mInfo As MENUITEMINFO hSubMenu = GetSubMenu(GetMenu(Me.hwnd), 0) mnuItemCount = GetMenuItemCount(hSubMenu) mInfo.cbSize = Len(mInfo) mInfo.fMask = MIIM_TYPE mInfo.fType = MFT_STRING mInfo.dwTypeData = Space$(256) mInfo.cch = Len(mInfo.dwTypeData) r = GetMenuItemInfo(hSubMenu, 1, True, mInfo) mInfo.fType = RGB_STARTNEWCOLUMNWITHVERTBAR mInfo.fMask = MIIM_TYPE r = SetMenuItemInfo(hSubMenu, 1, True, mInfo) End Sub |
Enjoy this article?
Filed under: Forms
Leave a comment