Results 1 to 3 of 3

Thread: Standard VB Dropdown Menu

  1. #1

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Standard VB Dropdown Menu

    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?
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

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

    Re: Standard VB Dropdown Menu

    Take a look at this sample (background and pattern):
    VB Code:
    1. Option Explicit
    2.  
    3. Private Enum MENUINFO_STYLES
    4.     MNS_NOCHECK = &H80000000
    5.     MNS_MODELESS = &H40000000
    6.     MNS_DRAGDROP = &H20000000
    7.     MNS_AUTODISMISS = &H10000000
    8.     MNS_NOTIFYBYPOS = &H8000000
    9.     MNS_CHECKORBMP = &H4000000
    10. End Enum
    11.  
    12. Private Enum MENUINFO_MASKS
    13.     MIM_MAXHEIGHT = &H1
    14.     MIM_BACKGROUND = &H2
    15.     MIM_HELPID = &H4
    16.     MIM_MENUDATA = &H8
    17.     MIM_STYLE = &H10
    18.     MIM_APPLYTOSUBMENUS = &H80000000
    19. End Enum
    20.  
    21. Private Type MENUINFO
    22.     cbSize As Long
    23.     fMask As MENUINFO_MASKS
    24.     dwStyle As MENUINFO_STYLES
    25.     cyMax As Long
    26.     hbrBack As Long
    27.     dwContextHelpID As Long
    28.     dwMenuData As Long
    29. End Type
    30.  
    31. Private Declare Function GetMenuInfo Lib "user32" (ByVal hMenu As Long, MI As MENUINFO) As Long
    32. Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, MI As MENUINFO) As Long
    33. Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    34. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    35.  
    36. Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
    37. Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, _
    38.     ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
    39.  
    40. Private Sub Form_Load()
    41. '=======================
    42. Dim MI As MENUINFO
    43. Dim mBrush As Long, hBitmap As Long
    44. Dim bBytes(1 To 999) As Byte
    45.  
    46.     For mBrush = 1 To 999
    47.         bBytes(mBrush) = 123
    48.     Next
    49.     hBitmap = CreateBitmap(3, 12, 1, 1, bBytes(1))
    50.    
    51.     With MI
    52.         .cbSize = Len(MI)
    53.         .fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
    54.         .hbrBack = CreateSolidBrush(vbYellow)
    55.         '.hbrBack = CreatePatternBrush(hBitmap)
    56.         SetMenuInfo GetMenu(Me.hwnd), MI
    57.     End With
    58.  
    59. End Sub

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Standard VB Dropdown Menu

    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

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