Re: Menu coloring using SetMenuInfo_ () not working with 64
Posted: Thu Dec 04, 2014 12:30 am
The menu bar or the menu items ?
The first code does nothing here, using PB 5.31 x86 on Win7 x64.
On the other hand adding #MIM_APPLYTOSUBMENUS
changes the background color of the menu items to yellow.
Still doesn't work on x64 though.
I don't think it's a terrific idea to change the bg color of a menu, not knowing what the foreground color is.
Well, I don't think it's a nice idea to change any color (OS themes are there for a good reason and you can piss off the user doing so), *unless* you owner draw all (maybe skinning your program entirely).
To make it work on x86 and x64 I've changed it as follow:
references:
MENUINFO
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Windows data types
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
The first code does nothing here, using PB 5.31 x86 on Win7 x64.
On the other hand adding #MIM_APPLYTOSUBMENUS
Code: Select all
\fMask = #MIM_BACKGROUND | #MIM_APPLYTOSUBMENUS
Still doesn't work on x64 though.
I don't think it's a terrific idea to change the bg color of a menu, not knowing what the foreground color is.
Well, I don't think it's a nice idea to change any color (OS themes are there for a good reason and you can piss off the user doing so), *unless* you owner draw all (maybe skinning your program entirely).
To make it work on x86 and x64 I've changed it as follow:
Code: Select all
#MIM_BACKGROUND = 2
#MIM_APPLYTOSUBMENUS = $80000000 ; added
Structure myMENUINFO Align #PB_Structure_AlignC ; added
cbSize.l
fMask.l
dwStyle.l
cyMax.l
hbrBack.i ; changed to HBRUSH, handle size -> pointer size
dwContextHelpId.l
*dwMenuData ; changed to ULONG_PTR -> http://msdn.microsoft.com/en-us/library/windows/desktop/aa384255%28v=vs.85%29.aspx
EndStructure
Debug SizeOf(myMENUINFO)
hMenuBrushBG = CreateSolidBrush_(RGB(255,255,0))
With mi.myMENUINFO
\cbSize = SizeOf(myMENUINFO)
\fMask = #MIM_BACKGROUND | #MIM_APPLYTOSUBMENUS ; added
\hbrBack = hMenuBrushBG
EndWith
If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateMenu(0, WindowID(0))
MenuTitle("Menü 1")
MenuItem(1,"Item 1")
MenuTitle("Menü 2")
MenuItem(2,"Item 2")
EndIf
Debug SetMenuInfo_(MenuID(0), mi)
DrawMenuBar_(WindowID(0))
Repeat
EventID=WaitWindowEvent()
If EventID=#PB_Event_CloseWindow
DeleteObject_(hMenuBrushBG)
Quit=1
EndIf
Until Quit=1
EndIf
MENUINFO
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Windows data types
http://msdn.microsoft.com/en-us/library ... 85%29.aspx