Hi,
Can any one tell me how can I change the color of the menubar?
I want to make it blue...
Please Help
Printable View
Hi,
Can any one tell me how can I change the color of the menubar?
I want to make it blue...
Please Help
The only way is to owner-draw the menubar and it is a rather complicated stuff which takes weeks of development to handle and make work well. Although something that simple might be slightly easier. If still interested, you can find more information by searching for owner-drawn menus.
From where I can find this owner drawn menu bar.......?
Try this
VB Code:
Option Explicit Private Type MENUINFO cbSize As Long fMask As Long dwStyle As Long cyMax As Long hbrBack As Long dwContextHelpID As Long dwMenuData As Long End Type Private Declare Function DrawMenuBar Lib "user32" _ (ByVal hwnd As Long) As Long Private Declare Function GetMenu Lib "user32" _ (ByVal hwnd As Long) As Long Private Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Long, _ ByVal bRevert As Long) As Long Private Declare Function SetMenuInfo Lib "user32" _ (ByVal hmenu As Long, _ mi As MENUINFO) As Long Private Declare Function CreateSolidBrush Lib "gdi32" _ (ByVal crColor As Long) As Long Private Declare Function OleTranslateColor Lib "olepro32.dll" _ (ByVal OLE_COLOR As Long, _ ByVal HPALETTE As Long, _ pccolorref As Long) As Long Private Const MIM_BACKGROUND As Long = &H2 Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000 Private Function SetMenuColour(ByVal hwndfrm As Long, _ ByVal dwColour As Long, _ ByVal bIncludeSubmenus As Boolean) As Boolean 'set application menu colour Dim mi As MENUINFO Dim flags As Long Dim clrref As Long 'convert a Windows colour (OLE colour) 'to a valid RGB colour if required clrref = TranslateOLEtoRBG(dwColour) 'we're changing the background, 'so at a minimum set this flag flags = MIM_BACKGROUND If bIncludeSubmenus Then 'MIM_BACKGROUND only changes 'the back colour of the main 'menu bar, unless this flag is set flags = flags Or MIM_APPLYTOSUBMENUS End If 'fill in struct, assign to menu, 'and force a redraw with the 'new attributes With mi .cbSize = Len(mi) .fMask = flags .hbrBack = CreateSolidBrush(clrref) End With SetMenuInfo GetMenu(hwndfrm), mi DrawMenuBar hwndfrm End Function Private Function TranslateOLEtoRBG(ByVal dwOleColour As Long) As Long OleTranslateColor dwOleColour, 0, TranslateOLEtoRBG End Function Private Sub Form_Load() 'Change RGB(180, 210, 240) to the color you want Call SetMenuColour(Me.hwnd, RGB(180, 210, 240), True) End Sub
Yeah!!! It is Working Fantastic..!! Thank You So Much Mr.Jcis.Quote:
Originally Posted by jcis
If this is resolved, please pull down the Thread Tools menu and click the Mark Thread Resolved button. That will let everyone know that you have your answer.
Thank you. :)
Nice one Jcis, I was also wondering if this was possible :eek2:
Works well