Page 1 of 1

Inline asm question

Posted: Wed Oct 15, 2003 9:15 pm
by fsw
How to obtain the gadget OS handle with inline asm :?:

In the 'PureBasic library descriptor.txt' file there is a info about the PB_GadgetStructure but I failed to obtain any information from this structure.

Any help is truly appreciated.

Another question would be how to use 'CustomData' and 'CustomData2'...

Thanks

Posted: Mon Nov 10, 2003 8:17 pm
by fsw
NOBODY :?:

Posted: Mon Nov 10, 2003 11:07 pm
by freak

Code: Select all

Structure PB_GadgetStructure
  Gadget.l    ; OS Gadget pointer (HWND)
  *VirtualTable
  CustomData.l  ; Can be used to store extra infos on this gadget
  CustomData2.l ; Can be used to store extra infos on this gadget
EndStructure

#MyGadget = 1

OpenWindow(0, 0, 0, 300, 300, #PB_Window_SystemMenu|#PB_Window_Screencentered, "example")
CreateGadgetList(WindowID())
TreeGadget(#MyGadget, 0, 0, 300, 300)

; _PB_Gadget ObjectsArea is a pointer to an array of PB_GadgetStructur structures.
; one for each gadget.
; We move that value to the GadgetBase variable
;
GadgetBase.l
!extrn _PB_Gadget_ObjectsArea
!mov eax, [_PB_Gadget_ObjectsArea]
!mov [v_GadgetBase], eax

; calculate the offset of the PB_GadgetStructure for our Gadget:
;
*MyGadget.PB_GadgetStructure = GadgetBase + SizeOf(PB_GadgetStructure) * #MyGadget

Debug *MyGadget\Gadget
Debug GadgetID(#MyGadget)

Repeat
Until WaitWindowEvent() = #PB_EventCloseWindow
The virtualtable member is a pointer to the list of functions for this
Gadget.
The CustomData and CustomData2 members are for the internal use
of the Gadget functions. So they can store values for each gadget.

TreeGadget for example stores the Item count in the CustomData
member, because the API function that count's tree items only returns
16bit values, and so limits the number of entrys to 65535 entrys. But
because the item count is stored here, the full 32bit range is avaiable.
CustomData2 contains a pointer to some internal data.

I can't tell you much about what other Gadgets store there, as i don't
know their sources :wink:

btw, wha exactly do you want to do?

Timo

Posted: Mon Nov 10, 2003 11:24 pm
by fsw
8)
Thanks Freak.

When I read the little text file coming with the SDK I got the impression that CustomData and CustomData2 are free to use :arrow: Custom :!:

But you are saying that they are already internally used - right :?:

So it's a BAD idea to use them and store something else in it, because it would screw up the whole thing - right :?:

And I thought I found a LEGAL place to store additional stuff for each gadget... :(

Posted: Mon Nov 10, 2003 11:29 pm
by freak
Yes, it is free to use, but only for the functions that create the Gadget :wink:

At least the Gadgets i have written make lot's of use of it, so better don't
overwrite the values there.

Timo