If you know an object type, and you have the object's handle (hwnd), is there a way to turn that into a variable?
Example:
Set myObj = Magic(hwnd)
If you know an object type, and you have the object's handle (hwnd), is there a way to turn that into a variable?
Example:
Set myObj = Magic(hwnd)
HWNDs are just numbers that are mapped to internal objects by the OS (and they can and do get recycled). You can't really turn them into anything.
What would you expect myObj to do in your example? All the Windows APIs for manipulating windowss take HWNDs.
You may be able to use GetObject() for COM, but it does have limitations -- you can't specify a particular hWnd, for one.
For example, you can get a running Excel instance using GetObject("", Excel.Application), but if there are multiple running instances, you won't know which one will be returned and there is no way to specify.