Page 1 of 1
Gadget help
Posted: Thu Mar 11, 2004 7:36 pm
by dwfait
Hi, im new to this forum, and to purebasic. I have just converted from BlitzBasic, because i wanted something a bit more powerful, and robust. I am doing a very small little project to help me learn the language, (not an MMOROREDGJOGDRGOERPG), its a small runescape toolkit in windows, however, i need a little help with the gadgets.
How do i tell which button/toolbar icon is being pressed, so i can do a message, or an action..etc..
for example, i want to see if button_3 was being pressed, do function(test)
i would appreciate any help, although code and an explanation would help me a lot.
Thank you.
Posted: Thu Mar 11, 2004 8:22 pm
by srod
Hello, welcome to Purebasic,
there are lots of examples packaged with Purebasic itself and even more to be found on sites such as
http://www.purearea.net/pb/english/index.htm
The following simple example gives a demonstration of a button gadget and checking whether it has been clicked etc.
Code: Select all
#Button1 = 1; I use this to identify the button.
;Each gadget must have its own identifier in order to distinguish it from other gadgets.
;-Startup code.
;Open windows and set up gadgets etc.
OpenWindow(1,0,0,800,600, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget,"Button demo.")
CreateGadgetList(WindowID())
ButtonGadget(#Button1, 100,300, 80, 25, "CLICK ME!")
;-Event loop.
Repeat
EventID=WaitWindowEvent();Forces PB to wait until Windows reports some event or other; e.g. user clicks a button.
Select EventID; Investigate the nature of the reported event.
Case #PB_Event_Gadget; Check to see if the reported event is associated with some PB gadget.
Select EventGadgetID();Identify the relevant gadget.
Case #Button1
MessageRequester("HELLO!", "You clicked the button!", #PB_MessageRequester_ok)
EndSelect
EndSelect
Until EventID=#PB_EventCloseWindow
End
Hope it helps.
Posted: Thu Mar 11, 2004 8:44 pm
by dwfait
Thank you srod.