Resolved Moving Sub Windows inside another program

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
Can you change the location and size of a sub window inside another program externally? I am running Nox, i could move the main window around from another program. But can you move around that Macro Recorder window or the toolstrip bar on the side around?
 
Without knowing anything about that application, it's hard to say for sure. It depends how it is built and what limitations it may apply. In general though, I would assume that you would call FindWindow to get the main window, then call FindWindowEx the appropriate number of times and in the appropriate manner to get the desired child window and then call SetWindowPos to position the child window.

This assumes that you're talking about actual child windows. If you're talking about tool windows that open separate to the main window then I would think that a single call to FindWindow would be enough.
 
with FindwindowEx i don't know which window is the one i want. I can find the window in spy++, can i use that info for something?
 
window is the one i want. I can find the window in spy++, can i use that info for something?
Indeed you can and you do. You need to identify the type of the window you want and the number of siblings of the same type before it, and then do the same for each container it is in, all the way up to the parent form. You call FindWindow to get the handle of the parent form, then you call FindWindowEx and specify that handle as the parent to get the handle of a child window. Once you have the handle of a child container, you can specify that as the parent to get its child windows. When you call FindWindowEx, you specify the type of the child window to get the first child of that type. You can then call it again and specify that you want to find the next child after that previous handle to get the second child of that type and so on. As an example, let's say that you want the second Edit window inside the second Container window:
  1. Call FindWindow to get the top-level window.
  2. Call FindWindowEx to get the first Container, specifying the handle from step 1 as the parent.
  3. Call FindWindowEx to get the second Container, specifying the handle from step 1 as the parent and to get the window after the handle from step 2.
  4. Call FindWindowEx to get the first Edit, specifying the handle from step 3 as the parent.
  5. Call FindWindowEx to get the second Edit, specifying the handle from step 3 as the parent and to get the window after the handle from step 4.
 
If you're still confused, post a screenshot of the Spy++ output for the top-level window you're interested in and its child window hierarchy down to the child window you're interested in.
 
With that i need to look down a lot of windows if it has lots of nested windows. with spy++ info, can i just zoom right to the window i want? i cant seem to get the window with the handle from spy++
 
I haven't used Spy++ for a while but I believe that there's a target symbol or the like that you can drag onto a window to zoom to it in the hierarchy. There's also other tools like WinID and Winspector - again, haven't used them for a while - that don't use a hierarchical view like Spy++ does, so one of them might help.
 
Yes i used the target symbol to get the window. It tells me that window's handle and it's parent's handle is the main window. Can i use the child window name or handle to find the window in vb?
 
Last edited:
It tells me that window's handle and it's parent's handle is the main window.
That seems to suggest that there is no child window. A window is defined by a handle so if there's only one handle then there's only one window. It seems like what looks like a child window is actually just drawn on the top-level window, much like if you used GDI+ to draw buttons on a Windows Form. Like I said in the first place, what you can do depends on how the application is built. It sounds like it's built in such a way that what you want to do is impossible.
 
Back
Top