Control Pseudo-object

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > UI (User Interface) > CONTROLS >

Control Pseudo-object

 

While thinBasic allows you to define and manipulate controls via procedural commands, it also introduces the concept of the Control Pseudo-objects.

 

Control Pseudo-objects are just standard user interface controls but with a unique name that allows control manipulation and events reactions using control name as main identifier inside scripts.

 

These Controls behave like standard Controls (have methods and properties), allow processing of events and make the whole process of control manipulation much easier, compared to the low level Win32 procedural way.

 

How do you create control pseudo-object variable?

 

They are created for you in the following cases:
 

DIALOG NEW created dialog from #RESOURCE (then control pseudo-objects named as the controls in the resource for given dialog are created)
 

Control Add ... indicating optional NAME parameter. thinBasic will create a run time control pseudo-object object identified by the control name.
Using the given name it is possible to interact with the control more easily to change control properties and react to control events.
 

An example

 

...
'---Add a button named myButton  

CONTROL ADD BUTTON Name myButton, hwnd, ctrlID, txt, xPos, yPos, Width, Height

 

'---myButton can be later used to manipulate new button

myButton.X =  10

myButton.Y =  10

myButton.W = 180

myButton.H =  32

myButton.Text = "Open"

...

 

'---Events can be intercepted adding an event handler choosing one of the handler available
CallBack Function myButton.OnSize() As Long
End Function
 
CallBack Function myButton.OnClick() As Long
End Function