owner draw menu

Windows specific forum
frederic
User
User
Posts: 56
Joined: Thu Jan 05, 2006 11:22 pm

owner draw menu

Post 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
eJan
Enthusiast
Enthusiast
Posts: 366
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Post by eJan »

Gray colored is a part of window, use SetWindowColor(#Window, Color) or draw Box onto WindowOutput(0).
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
frederic
User
User
Posts: 56
Joined: Thu Jan 05, 2006 11:22 pm

Post by frederic »

Cool, SetMenuInfo_() do the trick :)
but SetWindowColor(#Window, Color) no

merci pour tout
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: owner draw menu

Post 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)
ImageThe happiness is a road...
Not a destination
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Re: owner draw menu

Post 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:
Sorry for my english :wink: ! (Windows Xp, Vista and Windows 7, Windows 10)
User_Russian
Addict
Addict
Posts: 1597
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: owner draw menu

Post 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
Post Reply