Page 1 of 1

Return real handles also with #PB_ANY

Posted: Sun Jul 19, 2009 9:08 pm
by Marlin
help wrote:PureBasic - Gadget
...
If a static number was given to identify the gadget instead of #PB_Any, then the functions return the OS identifier for the created Gadget.
The same thing seems to apply to OpenWindow() too.

If we could also get the os handle when using #PB_ANY,
so that the gadget number would be the same as the gadget id,
we wouldn't need to take care for 2 sets of numbers identifying gadgets.

We could then use the gadget number for api, for GadgetType() etc.
in functions enhancing the functionality of gadgets...

This would be especially usefull as there seems to be no (simple) way
to get the gadget number (f.e. needed for GadgetType()) out of the handle.

And we would not need to use GadgetId() in that case :wink:

(If GadgetId() would be called, it would return the gadget number.)

Posted: Mon Jul 20, 2009 11:05 am
by Fred
It's not possible to associate user data to every type of API object, that's why it's not possible.

Posted: Tue Jul 21, 2009 12:15 pm
by akj
Marlin says:
This would be especially usefull as there seems to be no (simple) way
to get the gadget number (f.e. needed for GadgetType()) out of the handle.
Under Windows, this should get a gadget's number from it's handle hGad

Code: Select all

gadget = GetDlgCtrlID_(hGad)
This should also work

Code: Select all

gadget = getProp_(hGad, "PB_ID")
To get a window's number from it's handle hWnd, do this

Code: Select all

window = getProp_(hWnd, "PB_WindowID")-1

Posted: Tue Jul 21, 2009 1:12 pm
by Marlin
I am impressed to see these actually work.

If there are similarly easy ways to get PB ids from os handles for Linux [...],
maybe we could get a native PB function to do that too(?)

Posted: Wed Jul 22, 2009 8:14 am
by #NULL
so easy?
thanks akj! :)

Posted: Wed Jul 22, 2009 11:28 am
by Fred
This is internal hacks, it's not granted to work in the long run.