Results 1 to 40 of 44

Thread: Change Menu color?

Threaded View

  1. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Change Menu color?

    Ooo, that's my favorite - create one menu and at least one submenu item:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const MIM_BACKGROUND As Long = &H2
    4. Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000
    5.  
    6. Private Type MENUINFO
    7.     cbSize As Long
    8.     fMask As Long
    9.     dwStyle As Long
    10.     cyMax As Long
    11.     hbrBack As Long
    12.     dwContextHelpID As Long
    13.     dwMenuData As Long
    14. End Type
    15.  
    16. Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
    17. Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    18. Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
    19. Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, mi As MENUINFO) As Long
    20. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    21.  
    22. Private Sub Command1_Click()
    23. Dim mi As MENUINFO
    24.    
    25.     With mi
    26.         .cbSize = Len(mi)
    27.        
    28.         .fMask = MIM_BACKGROUND
    29.         .hbrBack = CreateSolidBrush(vbYellow)
    30.         SetMenuInfo GetMenu(Me.hWnd), mi  'main menu bar
    31.        
    32.         .fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
    33.         .hbrBack = CreateSolidBrush(vbCyan)
    34.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 0), mi 'this could a File menu perhaps
    35.     End With
    36.    
    37.     DrawMenuBar Me.hWnd
    38.  
    39. End Sub
    EDIT: my appologies - I should've mentioned that this sample was inspired by Randy Birch's original article (link in my signature).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width