Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpmii As MENUITEMINFO) As Long Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
Private 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
Private Sub Form_Load() Dim r As Long Dim hSubMenu As Long Dim mnuItemCount As Long Dim mInfo As MENUITEMINFO
'Replace the '0' below With the menu position. In thIs Case Put 0 because the menu that you 'want To Put split On it Is the first menu from the left. If the menu position was the second from 'the left, you've should been Put there '1'. 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) 'Replace the '1' below With your desirable split position. Put '1' To enter the split after 'the first Sub menu, Put '1' To Put it after the second Sub menu And so On. 'If you want To Put the split before the last Sub menu, Put there 'mnuItemCount - 1'. 'If you want To Put it before 2 Sub menus from the last, Put there 'mnuItemCount - 1'. 'If you replace the '1' Don't forGet To replace also the '1' in the line above the 'End Sub' r = GetMenuItemInfo(hSubMenu, 1, True, mInfo) mInfo.fType = RGB_STARTNEWCOLUMNWITHVERTBAR mInfo.fMask = MIIM_Type 'If you Replaced the '1' three lines above, replace the '1' below With the same number. r = SetMenuItemInfo(hSubMenu, 1, True, mInfo) End Sub
Если Вас заинтересовала или понравилась информация программирование на Visual Basic - "Положить разделить в меню", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу: Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!