Question about BindEvent()

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Question about BindEvent()

Post by SkyManager »

Referring to help menu about BindEvent(),
BindEvent(Event, @Callback() [, Window [, Object [, EventType]]])
It allows me to specify an Object.

For example,

Code: Select all

BindEvent(#PB_Event_SizeWindow, @MyEvent(), WindowID, GadgetID)
My question is :
How can I get the GadgetID from within the procedure MyEvent()
For example,

Code: Select all

Procedure.l MyEvent()
  ; Question <---- How to get and use the GadgetID??
endprocedure
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Question about BindEvent()

Post by Bisonte »

SkyManager wrote:Referring to help menu about BindEvent(),
BindEvent(Event, @Callback() [, Window [, Object [, EventType]]])
It allows me to specify an Object.

For example,

Code: Select all

BindEvent(#PB_Event_SizeWindow, @MyEvent(), WindowID, GadgetID)
My question is :
How can I get the GadgetID from within the procedure MyEvent()
For example,

Code: Select all

Procedure.l MyEvent()
  ; Question <---- How to get and use the GadgetID??
endprocedure
Don't confuse OS handle and PB object ID !

Code: Select all

Procedure.i MyEvent()
  ; Question <---- How to get and use the GadgetID??
  Protected Gadget = EventGadget() ; This is NOT the GadgetID (OS-Handle) 
  Protected Window = EventWindow() ; This is NOT the WindowID (OS-Handle)
  
  Debug WindowID(Window) ; <-- This is the WindowID
  
EndProcedure

BindEvent(#Event, @MyEvent(), Window, Gadget)

Window = OpenWindow(#PB_Any, 0, 0...... ; <---  Window = the PB Object ID

WindowID = OpenWindow(1, 0, 0..... ; WindowID = the OS-Handle (WindowID)
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Re: Question about BindEvent()

Post by SkyManager »

thanks for the clarification
Post Reply