WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Window Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Distinguish Parent and Child Windows

 Keywords: parent and child windows
 

Question:

WinItemChild should return a list of all the child windows under the parent. I would expect to see a list of window names. But instead I get a list of control captions (controls on the parent window). Child window name does not appear at all in the list, but it appears as a parent name if I querry with WinItemize.(Win95)

What am I missing? Please help.

Answer:

It is the definitions of child and parent windows that's the problem. Almost all controls happen to be child windows.

The big test is this:

Size the main parent window to take up only some of the screen. Now make a window you are interested in appear.

Can you grab the new window with the mouse and move it OFF the parent? If you can move it off the parent, it is also a parent window. If it stays inside the parent and is unable to move outside, it is a child.

However here is another test.

  1. Start the main application.

  2. Adjust size so I can see some of my wallpaper behind the application.

  3. Now I bring up the window I am wondering about.

  4. Then I grab the window with the mouse and attempt to move it over the wall paper.

  5. If I can move the window so that it can cover the wallpaper, then it is a parent window.

  6. If the window cuts off at the edge of the parent window, then it is a child window.
To see an example of each.
  1. Parent owned by another parent.

    Do a FileOpen in WinBatch studio. the OPEN window that pops up is a parent window

  2. A child window. Open a few wbt files in WinBatch studio. Select Window Menu Cascade so it arranges them all up nicely.

    Then grab one of them with a mouse and try to drag it over the wallpaper. Notice it cuts off at the edge of the main Winbatch Studio window. It is a child window.

Here's a script to help you separate the parent and child windows.

This code first of all makes a list of all parent windows, and allows you to choose one. Then it gets the list of all children of that parent for your perusal.

 
 parents=WinItemize()
 thisone=AskItemList("Choose a Parent Window",parents,@tab,@sorted,@single)
 children=WinItemChild(thisone)
 child=AskItemList("Children of %thisone%",children,@tab,@sorted,@single)
Or, if you continue to have problems with Sendkeys or SendkeysChild not working, it might be because you are not specifying the correct window title, or the window title might have additional spaces in the name, that are not apparent to the naked eye.

Here's a modified version of the parent child script to work with that shows the window title length, and substitutes question marks for spaces, so you can really see what's going on...

parents=WinItemize()
thisone=AskItemList("Choose a Parent Window",parents,@tab,@sorted,@single)

psize=strlen(thisone)
xxx=strreplace(thisone," ","?")
Message("Parent window size=%psize%",xxx)

children=WinItemChild(thisone)
child=AskItemList("Children of %thisone%",children,@tab,@sorted,@single)
csize=strlen(child)
xxx=strreplace(child," ","?")
Message("Child window size=%csize%",xxx)

One of our users also provided the following modified code to allow the Parent-Child Finder Script to run alongside the program, so that you can "single-step" through your program and use this program to tell you the Parent and Child names along the way.

: CODE STARTS HERE
while AskYesNo("Wincheck","Check another Window?")
allwins=Winitemize()
mywind=AskItemList("Windows",allwins,@tab,@unsorted,@single)
children=WinItemChild(mywind)
a=strreplace(children, @tab, @crlf)
message(mywind, a)
endwhile
: CODE ENDS HERE
When writing install code, you could have up 3 windows, the script above, the installing program itself and Notepad; then run through the install, get the names of the Windows and write the program "on the fly". Unless you get a syntax error, this works consistently with most Windows programs.
Article ID:   W13364
Filename:   Figure out parent and child windows.txt
File Created: 2001:05:24:13:29:14
Last Updated: 2001:05:24:13:29:14