Reference Manual

Creating Gadgets

PureBasic allows you to create your own gadgets through a special type of user libraries, which have the following common characteristics:

To allow creating gadgets with TailBite and without having to use inline ASM, a helper funcion, TB_RegisterGadget() is provided and installed with TailBite. (you just need to add an IncludeFile to the TB_GadgetExtension.pb file (it's in TailBite Folder/Helper Libraries)

But the best way to understand how this works is having a look at the included sample 'MyPaintBoxGadget'. There you'll see that, after creating the gadget or control, you call TB_RegisterGadget(ID, hWnd, @VT), 'ID' being the gadget index (#Gadget) used (which is given usually as first argument when your gadget creation function is called), 'hWnd' the Windows handle of your gadget or control and '@VT' the pointer to the (already filled) PB_GadgetVT structure. If your gadget doesn't process any of these functions, the corresponding member must be reset to 0 before passing the structure.
You should return what TB_RegisterGadget returns, in case the programmer uses #PB_Any

Please note that since the GadgetExtension lib has been re-added, the function names have changed.