find a window at x, y, z
Hi,
Is it possible to grab hold of a window at coordinates x, y ( and possible z?). I'm not too bothered about the z values of the window as its going to be the top most window anyway.
Thanks Matt.
[220 byte] By [
flynny1st] at [2007-11-20 8:31:59]

# 1 Re: find a window at x, y, z
Not very clear what do you want: to find a window at x, y, z or to place a window at x, y, z ?
# 2 Re: find a window at x, y, z
I don't think that it is a function for that.
You can write one though using EnumWindows (or GetTopWindow if you know that it is topmost), GetWindowRect and then match with x & y
S_M_A at 2007-11-9 13:31:24 >

# 3 Re: find a window at x, y, z
hi thanks for the replies. sorry it wasn't that clear.
I've hooked into an application window, and i want to then grab hold of the handle of a child window held inside it. The problem is that this child window is nested in about ten other windows.
the other problem is that the window contains multiple instances of the same class.
for example if im hooked into window a
window a contains windows b and c (both are of the same class.) how can i distinguish between these two? as both have no text (size?).
Thanks Matt.
# 4 Re: find a window at x, y, z
Finding them is easy with EnumChildWindows, how to decide which your target is is harder...
You have to find something that differs or else your back to your initial coord matching again.
S_M_A at 2007-11-9 13:33:26 >

# 5 Re: find a window at x, y, z
I was thinking of removing the resize option on the window and then using the sizes of the windows along ith the classes? does this sound ok?
Thanks Matt.
# 6 Re: find a window at x, y, z
Sounds ok but if you have the code can't you use Set/GetWindowWord to identify the child windows?
S_M_A at 2007-11-9 13:35:35 >

# 7 Re: find a window at x, y, z
Hi thanks for the reply,
can you elaborate on using the GetWindowWord idea?
do you mean pull out some unique attribute using this method?
Matt.
# 8 Re: find a window at x, y, z
Since it seemed that you have access to the code that creates all windows I thought you could use CWindow::SetWindowWord to set a unique value for each different window with the same class and use that to separate them out later on.
PS Don't forget to allocate that extra memory at window class registration. DS
S_M_A at 2007-11-9 13:37:29 >

# 9 Re: find a window at x, y, z
Unfortunately i dont have access to the code creating all the windows ( unless i can do this through WM_CREATE? )
# 10 Re: find a window at x, y, z
Ok I thought you had the code since you stated "I was thinking of removing the resize option on the window" but that's maybe an option in the program in question. If so, I don't know of any other option than to use the size.
S_M_A at 2007-11-9 13:39:37 >

# 11 Re: find a window at x, y, z
no, sorry for not been clear enough, i'll give that a go. Thanks for your help SMA.
# 12 Re: find a window at x, y, z
You're welcome
S_M_A at 2007-11-9 13:41:43 >

# 13 Re: find a window at x, y, z
if you don't mind, could you please tell me why you do not have access to the code that creates the windows, but you do have access to WM_CREATE? Just curious, seems unlikely to me.
# 14 Re: find a window at x, y, z
yes no problem, the program is a third party one that i haven't developed, i have hooked into its event using setwindowshookex, this is why i have access to the WM_CREATE event when it creates it child windows.
# 15 Re: find a window at x, y, z
Use WindowFromPoint
POINT pt;
pt.x = x;
pt.y = y;
HWND hwnd = WindowFromPoint(pt);