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.
 
I used the target button and this is the window. Nox4 is the main window.
 

Attachments

  • Screenshot 2021-08-23 031027.jpg
    Screenshot 2021-08-23 031027.jpg
    35.6 KB · Views: 22
  • Screenshot 2021-08-23 031107.jpg
    Screenshot 2021-08-23 031107.jpg
    41.6 KB · Views: 19
So, in that example, the main window has handle 0x00951074 and caption "Nox4" and the child window you want has handle 0x0168173C and caption "Nox_2", right? What class is that child window and how many siblings does it have of the same class before it in the hierarchy?
 
how do i know how many siblings or the class
 

Attachments

  • Screenshot 2021-08-23 042401.jpg
    Screenshot 2021-08-23 042401.jpg
    36.2 KB · Views: 21
  • Screenshot 2021-08-23 042517.jpg
    Screenshot 2021-08-23 042517.jpg
    72.4 KB · Views: 19
You know the class because the first screenshot in post #14 tells you what it is: Qt5QWindow. You know how many siblings because the second screenshot in post #14 shows you all the windows in the hierarchy and tells you their type, so you just look at the windows before the one you want and count how many have the same type. If your window of interest is the first of its type then you only need to call FindWindowEx once. If there are siblings then you need to call it once more for each. If the top-level window is the direct parent then you call FindWindow once to get that handle, then you call FindWindowEx the requisite number of times. The first time you call FindWindowEx, you don't specify a handle to search after. On each subsequent call, you specify the handle from the last call to search after. Once you get the first handle, you search after that to get the second and after that to get the third and so on.
 

Latest posts

Back
Top