Page 1 of 1

PopupMenu and bold items

Posted: Sun Sep 26, 2004 4:30 pm
by Armoured
Hi.
How I can make a bold item in a popup menu?


Thanks.

Posted: Sun Sep 26, 2004 5:30 pm
by GreenGiant
You need the api SetMenuItemInfo (see here) I wrote a quick example, basically you have to set one menu item as default, you choose which item by its position.

Code: Select all

#MIIM_STATE=1
#MFS_DEFAULT=4096

OpenWindow(0,0,0,400,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered,"test")
CreatePopupMenu(0)
MenuItem(0,"Normal1")
MenuItem(1,"Normal2")
MenuItem(2,"Bold")
MenuItem(3,"Normal3")

bold.MENUITEMINFO
bold\cbSize=SizeOf(bold)
bold\fMask=#MIIM_STATE 
bold\fState=#MFS_DEFAULT 
SetMenuItemInfo_(MenuID(),2,#True,bold) ;2 specifies the item to be made bold

Repeat
ev=WaitWindowEvent()
  If ev=#WM_RBUTTONUP
    DisplayPopupMenu(0,WindowID(0))
  EndIf
Until ev=#PB_Event_CloseWindow
Hope this helps.

Posted: Sun Sep 26, 2004 6:33 pm
by Armoured
Hi.
I can't find the MenuID() procedure in the Purabasic manual.
Where you have found informations about MenuID()?

Thanks.

Posted: Sun Sep 26, 2004 7:22 pm
by GreenGiant
To be honest I just guessed that would be the command, typed it, saw it was recognised and thought no more about it. My thinking was that it'd be dealt with the same as WidnowID() and GadgetID() so I didn't even bother to check the manual. Maybe its now unsupported?

Posted: Sun Sep 26, 2004 8:12 pm
by ABBKlaus
it seems that the hidden MenuID() command is the same like this :

Code: Select all

PeekL(IsMenu(0)

Posted: Sun Sep 26, 2004 8:55 pm
by GreenGiant
ABBKlaus, how did you know that the IsMenu function returned a memory address of a handle to the menu? I can't see anything about that in the helpfiles, and I've never seen it used before. Does seem to work though. Strange.