Object handle explained

can anyone explain to me how to use a window handle ?
I have the impression that it acts like a pointer to an object.
I tried something like this:

dim wHandle as integer
wHandle = wMainwondow.handle

wanted to use it like


but that does not work.

Handles are pretty much used for Declares…

wMainwindow.functionName is how you would do it…

You may want to have a look on this thread https://forum.xojo.com/13244-nssearchfield where way below Jim gives an explanation on how to translate Apple Dev docs to Xojo declares (other OS’ work similar).

In short: Yes, the window handle (like the handle of every object) is a ptr to this instance. Because Xojo objects are based on real OS objects, you can use the API calls for the appropriate class with a declare that needs a Ptr to the object to address it.

If you program for Mac OS X for example and want to center the window, you can just add a method to it (or a subclass for easier re-use):

[code]Sub Center()
//@header Sets the window’s location to the center of the screen.

#if TargetMacOS
declare sub center lib “Cocoa.framework” selector “center” (obj_id as integer)

center me.handle

End Sub[/code]
And that’s where the handle is needed.

I’ve used object handles as identifiers. For example, I have a particular object that gets stored in a dictionary for passing through to a class interface. The key for the dictionary is the object’s handle and the value in the dictionary is the object itself. So I’m always able to easily check from within the object if it is in the dictionary or not.

thanks guys, I have to handle it a different way