This question refers to the standard VB dropdown menu created from Tools/Menu Editor in the IDE.
Is it possible to change either its backcolor or the forecolor, or preferabley both?
Printable View
This question refers to the standard VB dropdown menu created from Tools/Menu Editor in the IDE.
Is it possible to change either its backcolor or the forecolor, or preferabley both?
Take a look at this sample (background and pattern):
VB Code:
Option Explicit Private Enum MENUINFO_STYLES MNS_NOCHECK = &H80000000 MNS_MODELESS = &H40000000 MNS_DRAGDROP = &H20000000 MNS_AUTODISMISS = &H10000000 MNS_NOTIFYBYPOS = &H8000000 MNS_CHECKORBMP = &H4000000 End Enum Private Enum MENUINFO_MASKS MIM_MAXHEIGHT = &H1 MIM_BACKGROUND = &H2 MIM_HELPID = &H4 MIM_MENUDATA = &H8 MIM_STYLE = &H10 MIM_APPLYTOSUBMENUS = &H80000000 End Enum Private Type MENUINFO cbSize As Long fMask As MENUINFO_MASKS dwStyle As MENUINFO_STYLES cyMax As Long hbrBack As Long dwContextHelpID As Long dwMenuData As Long End Type Private Declare Function GetMenuInfo Lib "user32" (ByVal hMenu As Long, MI As MENUINFO) As Long Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, MI As MENUINFO) As Long Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, _ ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long Private Sub Form_Load() '======================= Dim MI As MENUINFO Dim mBrush As Long, hBitmap As Long Dim bBytes(1 To 999) As Byte For mBrush = 1 To 999 bBytes(mBrush) = 123 Next hBitmap = CreateBitmap(3, 12, 1, 1, bBytes(1)) With MI .cbSize = Len(MI) .fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS .hbrBack = CreateSolidBrush(vbYellow) '.hbrBack = CreatePatternBrush(hBitmap) SetMenuInfo GetMenu(Me.hwnd), MI End With End Sub
Nice code.
You may want to check out www.vbAccelerator.com
This has some free OCX's, and DLLs, for creating professional looking menus.
VERY cool effects. Take a peek at their demo projects. Full source code to everything is given.
Woka