RosettaCodeData/Task/Simple-windowed-application/PureBasic/simple-windowed-application...

28 lines
895 B
Plaintext

Define window_0
Define window_0_Text_0, window_0_Button_1
Define clicks, txt$, flags
flags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered
window_0 = OpenWindow(#PB_Any, 408, 104, 280, 45, "Simple windowed application", flags)
If window_0
SmartWindowRefresh(window_0, #True)
window_0_Text_0 = TextGadget(#PB_Any, 5, 5, 165, 20, "There have been no clicks yet")
window_0_Button_1 = ButtonGadget(#PB_Any, 190, 10, 85, 30, "Click me")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case window_0_Text_0
Case window_0_Button_1
clicks + 1
txt$ = "You Clicked " + Str(clicks) + " time"
If clicks > 1: txt$ + "s": EndIf
SetGadgetText(window_0_Text_0, txt$)
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf