PopupMenu and bold items

Just starting out? Need help? Post your questions and find answers here.
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

PopupMenu and bold items

Post by Armoured »

Hi.
How I can make a bold item in a popup menu?


Thanks.
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post 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.
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Post by Armoured »

Hi.
I can't find the MenuID() procedure in the Purabasic manual.
Where you have found informations about MenuID()?

Thanks.
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post 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?
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

it seems that the hidden MenuID() command is the same like this :

Code: Select all

PeekL(IsMenu(0)
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

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