this template is for purebasic 5.xx and above
First we design our form in the form designer, and then save it as "Form.pbf" on our computer.
Code: Select all
Global Window_0
Global Button_0
Enumeration #PB_Compiler_EnumerationValue
#MenuItem_2
EndEnumeration
Procedure OpenWindow_0()
Window_0 = OpenWindow(#PB_Any, 0, 0, 270, 80, "GUI Code Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateMenu(0, WindowID(Window_0))
MenuTitle("File")
MenuItem(#MenuItem_2, "Derp Im'a Menu Item!")
Button_0 = ButtonGadget(#PB_Any, 10, 10, 250, 40, "Derp Im'a Button!")
EndProcedure
Code: Select all
XIncludeFile "Form.pbf" ;We include our form file made with the form designer
OpenWindow_0() ;Call the OpenWindow_0() function to initiate the window
Repeat ;Begin our main loop
EventID = WaitWindowEvent() ;Wait for a window event, and store the event ID into the EventID variable
Select EventID ;Once an event is triggered select the EventID
Case #PB_Event_Menu ;If the triggered event was a Menu event
Select EventMenu() ;Select the menu item responsible for the event
Case #MenuItem_2 ;If the menu item was #MenuItem_1
MessageRequester("Notice", "Menu Item Selected!")
EndSelect
Case #PB_Event_Gadget ;If the triggered event was a Gadget event
Select EventGadget() ;Select the Gadget responsible for the event
Case Button_0 ;If the Gadget was Button_0
MessageRequester("Notice", "Button Gadget Selected!")
EndSelect
Case #PB_Event_CloseWindow ;If the triggered event was a close window event
End
EndSelect
ForEver
Have fun!
