Return real handles also with #PB_ANY

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Return real handles also with #PB_ANY

Post 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.)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It's not possible to associate user data to every type of API object, that's why it's not possible.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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
Anthony Jordan
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Post 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(?)
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

so easy?
thanks akj! :)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

This is internal hacks, it's not granted to work in the long run.
Post Reply