Page 1 of 1

owner draw menu

Posted: Thu Mar 15, 2007 12:10 am
by frederic
Hello, i do some test on owner draw menu and i can't paint the rest of menubar, i can paint only "items", any idea ?

Image

thanks
Fred

Posted: Thu Mar 15, 2007 12:34 am
by eJan
Gray colored is a part of window, use SetWindowColor(#Window, Color) or draw Box onto WindowOutput(0).

Posted: Thu Mar 15, 2007 1:58 am
by Sparkie
I haven't tested with an ownerdrawn Menu, but API SetMenuInfo_() should do the trick.

Code: Select all

#MIM_BACKGROUND = 2

Structure myMENUINFO
  cbSize.l
  fMask.l
  dwStyle.l
  cyMax.l
  hbrBack.l
  dwContextHelpId.l
  dwMenuData.l
EndStructure

hMenuBrushBG = CreateSolidBrush_(RGB(255, 255, 100)) 

With mi.myMENUINFO
  \cbSize = SizeOf(myMENUINFO)
  \fMask = #MIM_BACKGROUND
  \hbrBack = hMenuBrushBG
EndWith

If OpenWindow(0, 10, 10, 300, 200, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
  hMenu = CreateMenu(0, WindowID(0)) 
  MenuTitle("File") 
  MenuItem(1, "Open") 
  MenuItem(2, "Save") 
  MenuItem(3, "Close") 
  MenuTitle("Edit") 
  MenuItem(4, "Cut") 
  MenuItem(5, "Copy") 
  SetMenuInfo_(hMenu, mi)
  DrawMenuBar_(WindowID(0)) 
  Repeat 
    Event = WaitWindowEvent() 
  Until Event = #PB_Event_CloseWindow 
  DeleteObject_(hMenuBrushBG) 
EndIf 
End

Posted: Thu Mar 15, 2007 9:13 am
by frederic
Cool, SetMenuInfo_() do the trick :)
but SetWindowColor(#Window, Color) no

merci pour tout

Re: owner draw menu

Posted: Thu Apr 22, 2010 5:26 pm
by Kwai chang caine
Great code.... :shock:
But is it possible to change also the font color ??? :roll:

Because, i want to color the menu in black....and i loose my font alone in the dark :(

Thanks to your help 8)

Re: owner draw menu

Posted: Fri Apr 23, 2010 2:23 pm
by GeBonet
Hi,
See also, the PureCOLOR library by de Gnozal, Coloring gadgets
And now with colors for menus and Items !
in Purebasic as simply as possible. Works for almost all gadgets, including standard ButtonGadgets. :!:
:roll:

Re: owner draw menu

Posted: Thu Apr 29, 2010 12:06 pm
by User_Russian
i do some test on owner draw menu and i can't paint the rest of menubar, i can paint only "items", any idea
Use API functions CreateSolidBrush, FillRect, DeleteObject

Result
Image