' SimpleMenu.bas

#include once "inc/iup.bi"

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub

' function mnue exit item 
function mnu_exit cdecl (ih as Ihandle ptr) as integer
  return IUP_CLOSE
end function
  

dim as IHandle ptr MyMenu = IupMenu( _
                              IupSubmenu("File", _
                                IupMenu( _
                                  IupSetAttributes(IupItem("&Open", NULL),"ACTIVE=NO"), _
                                  IupSetAttributes(IupItem("&Save", NULL),"ACTIVE=NO"), _
                                  IupSeparator(), _
                                  IupItem("E&xit","mnu_exit"), _
                                  NULL) _ ' end of list
                              ), _
                              NULL) ' end of list

' mnu exit ACTION function
IupSetFunction("mnu_exit",@mnu_exit )

' create a named menu handle for the dialog
IupSetHandle("MyMenu", MyMenu)

dim as IHandle ptr clientregion = IupHBox(IupSetAttributes(IupCanvas(NULL),"RASTERSIZE=640x480"),NULL)


dim as IHandle ptr dlg = IupDialog(clientregion)
IupSetAttribute(dlg, "TITLE", "mnue.bas")
' add the menu to the dialog via named handle
IupSetAttribute(dlg, "MENU", "MyMenu")

IupShow(dlg)
IupMainLoop()
