Page 1 of 2 12 LastLast
Results 1 to 40 of 44

Thread: Change Menu color?

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Change Menu color?

    Is it possible to change the color of the menu on the top of your vb program? The menu im talking about is in Tools->Menu Editor

    Once you make it, it stays stupid gray and i wanted to know how i could change it!...thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    The most I was ever to do was change the color on the menuitems, but not the actual menubar
    that is always displayed. You need some APIs to color the submenus. Interested still?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #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).

  4. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    edit**
    durr "Command1"

    thanks alot again!

    edit2**
    there a way to change the text color also?

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    Prop to you RB! I had worked on this a few years ago and couldnt get the main menubar.

    's up!

    Oh ya and heres a half dozen Reps even though you dont want them
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    i wish i could rate him but i cant : (

    can i get a pic on there too?

  7. #7

  8. #8

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    nice, but can you lead me in the right direction for which section to go to?

  9. #9

  10. #10

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    thats a good thread! im sorry to keep bugging you, but how could i use a rgb value?

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Change Menu color?

    You can use this:

    VB Code:
    1. Form1.BackColor = RGB(22, 44, 66)

  12. #12

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    cool, ill try and use that

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Change Menu color?

    After coming back to this, I thought that you wanted to change the menu still.

    Glad it was a new question.

  14. #14

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    it works. thanks alot guys!

    you had exactly what i was looking for

  15. #15

  16. #16

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    wow thankyou sooo much, you made me the most beautiful GUI!

  17. #17

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    And heres how i used it!:
    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" _
    17.     (ByVal hWnd As Long) As Long
    18.  
    19. Private Declare Function GetSubMenu Lib "user32" _
    20.     (ByVal hMenu As Long, ByVal nPos As Long) As Long
    21.  
    22. Private Declare Function GetMenu Lib "user32" _
    23.     (ByVal hWnd As Long) As Long
    24.  
    25. Private Declare Function SetMenuInfo Lib "user32" _
    26.     (ByVal hMenu As Long, _
    27.      mi As MENUINFO) As Long
    28.  
    29. Private Declare Function CreateSolidBrush Lib "gdi32" _
    30.     (ByVal crColor As Long) As Long
    31.  
    32. Private Sub Command1_Click()
    33. Dim mi As MENUINFO
    34.    
    35.     With mi
    36.         .cbSize = Len(mi)
    37.        
    38.         .fMask = MIM_BACKGROUND
    39.         .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    40.         SetMenuInfo GetMenu(Me.hWnd), mi  'main menu bar
    41.                 .fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
    42.         .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    43.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 0), mi 'File menu (item 0)
    44.                 .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    45.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 1), mi 'Edit menu (item 1)
    46.                 .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    47.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 2), mi 'Select menu (item 2)
    48.             End With
    49.         DrawMenuBar Me.hWnd
    50.  
    51. End Sub

    its a very very nice orange color

  18. #18
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Change Menu color?

    Post a picture

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    So its an Orange menu? I thougt you were going to use a texture or image background?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20

  21. #21

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    you want an awesome pic? here it is.

    Another few questions, how can i change the scrollbar color? i just want it a bit darker.
    Last edited by |2eM!x; Apr 12th, 2005 at 08:13 PM.

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    Ah, so the bitmap was for the forms background.



    What type of app is this going to be?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    its for a game, lets you get updates and such

    is there a way to add a picture behind a textbox so you can see it?

  24. #24
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    Not that I know of off hand, but if you can use a label control instead then the background can show
    through when its set to transparent.
    Is that what you need?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  25. #25

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    no, they need to be able to type into it : (, i think itd look really neat to have a picture behind it, ill try and do it myself but all know how that will end up

  26. #26
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    But then wouldnt it be hard to see the text?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  27. #27

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    i guess so, but i was going to make it somewaht transparent and on the left, as you can see i dont have very much room on my form..maybe ill just leave it out.

  28. #28

  29. #29

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    um, well im not sure what im supposed to do with that...

    i tested out, but what am i supposed to do? Drag the label around?

    it doesnt go over the textboxes either in my vb : (

  30. #30

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    wow, i figured it out, but i had to move the picture box over the text before runtime..
    thanks again!

    edit**
    wait then they wont be able to type in the textbox : (
    thanks anyways, ill just leave it

  31. #31
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    You could probably fake it when the user clicks the picture box. When this happens you can place the pb behind
    the textbox and the textbox will be in fornt ready for entries. Then switch back when the cursor leaves focus.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  32. #32

  33. #33

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    yes, but they cant type thru it..its fine i just wont use it

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

    Re: Change Menu color?

    Quote Originally Posted by |2eM!x
    yes, but they cant type thru it. ...
    Not sure I follow you. Do you want them to type or not? Sample I posted does allow this so what's the problem? If you don't want to allow typing then simply set Text1.Locked = True - that's it.

  35. #35
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Change Menu color?

    Quote Originally Posted by |2eM!x
    And heres how i used it!:
    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" _
    17.     (ByVal hWnd As Long) As Long
    18.  
    19. Private Declare Function GetSubMenu Lib "user32" _
    20.     (ByVal hMenu As Long, ByVal nPos As Long) As Long
    21.  
    22. Private Declare Function GetMenu Lib "user32" _
    23.     (ByVal hWnd As Long) As Long
    24.  
    25. Private Declare Function SetMenuInfo Lib "user32" _
    26.     (ByVal hMenu As Long, _
    27.      mi As MENUINFO) As Long
    28.  
    29. Private Declare Function CreateSolidBrush Lib "gdi32" _
    30.     (ByVal crColor As Long) As Long
    31.  
    32. Private Sub Command1_Click()
    33. Dim mi As MENUINFO
    34.    
    35.     With mi
    36.         .cbSize = Len(mi)
    37.        
    38.         .fMask = MIM_BACKGROUND
    39.         .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    40.         SetMenuInfo GetMenu(Me.hWnd), mi  'main menu bar
    41.                 .fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
    42.         .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    43.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 0), mi 'File menu (item 0)
    44.                 .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    45.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 1), mi 'Edit menu (item 1)
    46.                 .hbrBack = CreateSolidBrush(RGB(244, 147, 8))
    47.         SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 2), mi 'Select menu (item 2)
    48.             End With
    49.         DrawMenuBar Me.hWnd
    50.  
    51. End Sub

    its a very very nice orange color
    im not able to apply color to drop down menus in menu editor?

  36. #36

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    What??

    The code colors both the menu and the submenu items..

  37. #37
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Change Menu color?

    Quote Originally Posted by |2eM!x
    What??

    The code colors both the menu and the submenu items..
    not for me... seems something is se wrong?

  38. #38

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Change Menu color?

    Did you add a command button and click it

  39. #39
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Change Menu color?

    Quote Originally Posted by |2eM!x
    Did you add a command button and click it
    added it form_load. its not changing drop downs tho.

  40. #40
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Change Menu color?

    This flag (MIM_APPLYTOSUBMENUS) should be painting the submenus. Can you attach a sample project showing the issue?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Page 1 of 2 12 LastLast

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