Public Const MIM_BACKGROUND As Long = &H2
Public Const MIM_APPLYTOSUBMENUS As Long
Pubkic Type MENUINFO
cbSize As Long
fMask As Long
dwStyle As Long
cyMax As Long
End Type
.fMask=MIM_BACKGROUND
.hbrBack=CreateSolidBrush(vbYellow)
SetMenuInfo GetMenu(Me.hwnd),mi
.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
.hbrBack=CreateSolidBrush(vbCyan)
SetMenuInfo GetSubMenu(GetMenu(Me.hwnd),0),mi
.hbrBack=CreateSolidBrush(vbGreen)
SetMenuInfo GetSubMenu(GetMenu(Me.hwnd),1),mi
.hbrBack=CreateSolidBrush(vbRed)
SetMenuInfo GetSubMenu(GetMenu(Me.hwnd),2),mi
tagMENUITEMINFOA {
UINT cbSize;
UINT fMask;
UINT fType;
UINT fState;
UINT wID;
HMENU hSubMenu;
HBITMAP hbmpChecked;
HBITMAP hbmpUnchecked;
ULONG_PTR dwItemData;
LPSTR dwTypeData;
UINT cch;
HBITMAP hbmpItem;
fMask
- MIIM_FTYPE
- 0x00000100
| Retrieves or sets thefType member. |
- MIIM_ID
- 0x00000002
| Retrieves or sets thewID member. |
- MIIM_STATE
- 0x00000001
| Retrieves or sets thefState member. |
- MIIM_STRING
- 0x00000040
| Retrieves or sets thedwTypeDatamember. |
fType
- MFT_RIGHTJUSTIFY
- 0x00004000L
| Right-justifies the menu item and any subsequent items. This value is valid only if the menu item is in a menu bar. |
- MFT_RIGHTORDER
- 0x00002000L
| Specifies that menus cascade right-to-left (the default is left-to-right). This is used to support right-to-left languages, such as Arabic and Hebrew. |
- MFT_SEPARATOR
- 0x00000800L
| Specifies that the menu item is a separator. A menu item separator appears as a horizontal dividing line. ThedwTypeData andcch members are ignored. This value is valid only in a drop-down menu, submenu, or shortcut menu. |
- MFT_STRING
- 0x00000000L
| Displays the menu item using a text string. ThedwTypeDatamember is the pointer to a null-terminated string, and the cchmember is the length of the string. MFT_STRING is replaced by MIIM_STRING. |
Public Sub SetMenuBackground()
MenuHandle = GetSystemMenu(form.Handle,0)
Dim brush
Brush=CreateSolidBrush(RGB(200,100,200))
Dim mi As MenuInfo
mi.cbSize=Len(MenuInfo)
mi.fMask=&H2
mi.hbrBack=brush
SetMenuInfo(MenuHandle,mi)
End Sub
Private Sub Form_Load()
Dim ret As Long
Dim hMenu As Long
Dim hBrush As Long
Dim lbBrushInfo As LOGBRUSH
Dim miMenuInfo As tagMENUINFO
lbBrushInfo.lbStyle=BS_SOLID
lbBrushInfo.lbColor=RGB(155, 100, 200)
lbBrushInfo.lbHatch = 0
hBrush=CreateBrushIndirect(lbBrushInfo)
hMenu = GetMenu(Me.hwnd)
miMenuInfo.cbSize = Len(miMenuInfo)
ret=GetMenuInfo(hMenu, miMenuInfo) ' 0 means failure
miMenuInfo.fMask =MIM_BACKGROUND
'MIM_APPLYTOSUBMENUS use this to apply to submenus as well
miMenuInfo.hbrBack=hBrush
ret=SetMenuInfo(hMenu,miMenuInfo) '0 means failure
End Sub