PVDynamic_AddMenuBarIcon (WindowID.l,MenuBarID.l,Text.s,IconID.l)

Top  Previous  Next

Convert a regular MenuBar Item into a PBGadgets MenuBar Icon.

 

Use:

Result=PVDynamic_AddMenuBarIcon(#Window,#Gadget,"Save As...",#Icon)

 

Returns 0 if failure

 

 

Note: Once a MenuBar Item has been converted to a MenuBarIcon, it is no longer affected by the commands SetMenuItemState()

 

 

 

Example:

 

Init_PVDynamic()

#Window_Main=0

#MenuBar_Main=1

#MenuBar_Main_Exit=2

#MenuBarIcon_Main_Exit=2

 

LoadImage(#MenuBarIcon_Main_Exit,"images\exit.ico")

 

 

Procedure WindowCallback(WindowID,Message,wParam,lParam)

ReturnValue=#PB_ProcessPureBasicEvents

If Message=#WM_MEASUREITEM

ReturnValue=PVDynamic_MenuBarSize(WindowID,lParam)

EndIf

If Message=#WM_DRAWITEM

ReturnValue=PVDynamic_MenuBar(lParam,-1,-1)

EndIf

ProcedureReturn  ReturnValue

EndProcedure

 

 

If OpenWindow(#Window_Main,175,0,400,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Menu")

CreateMenu(#MenuBar_Main,WindowID(#Window_Main))

MenuTitle("File")

MenuItem(#MenuBar_Main_Exit,"Exit")

PVDynamic_AddMenuBarIcon(#Window_Main,#MenuBar_Main_Exit,"Exit",#MenuBarIcon_Main_Exit)

PVDynamic_DisplayMenuBarIcon()

 

SetWindowCallback(@WindowCallback())

 

Repeat

Until WaitWindowEvent()=#PB_Event_CloseWindow

EndIf