Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal bool As Boolean, lpcMenuItemInfo 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 Command1_Click() Dim MnuInfo As MENUITEMINFO
mnuH& = GetMenu(Me.hwnd) MnuInfo.cbSize = Len(MnuInfo) MnuInfo.fMask = MIIM_Type 'If you want To align To right Only few menus, And leave the rest in left side, 'Replace the '0' below And the '0' two lines above the 'End Sub' With the number 'of menus you want To leave in the left side. myTemp& = GetMenuItemInfo(mnuH&, 0, True, MnuInfo) MnuInfo.fType = MFT_RIGHTJUSTIFY Or MFT_String 'Replace all 'MenuCaption' below With the caption of the first menu from left. MnuInfo.cch = Len("MenuCaption") MnuInfo.dwTypeData = "MenuCaption" MnuInfo.cbSize = Len(MnuInfo) myTemp& = SetMenuItemInfo(mnuH&, 0, True, MnuInfo) myTemp& = DrawMenuBar(Me.hwnd) End Sub
Если Вас заинтересовала или понравилась информация программирование на Visual Basic - "Выравнивание меню по правому краю формы", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу: Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!