Inline asm question

Everything else that doesn't fall into one of the other PB categories.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Inline asm question

Post 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
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

NOBODY :?:
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post 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... :(

I am to provide the public with beneficial shocks.
Alfred Hitshock
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
Post Reply