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

Control Manager
plus
plus

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

An Explanation of cWndInfo


Basically there is a top level window. Lets call this the prime window. This prime window may have child windows.

All the child windows at this level are "siblings" (like brothers and sisters), and the prime window is their parent window.

Now all these child windows can have their own child windows. (We will call them grandchildren)

And so on

So each child window has one parent window. Each child window may have any number of "siblings" made by the same parent. And each child window may create their own child (grandchildren) windows.

Only the Prime window has no parent.

so the key words here are: "top level parent (aka prime)", "parent", "sibling", and "Child"

Each of these windows is identified internally by a number called a "window handle". If you look at the numerical values of the window handles, you can see that they have little or no relationship to each other.

So the cWndInfo function allows you to explore the relationships between various windows.

each individual window (and *almost everything* is a window of some kind)

keeps track of 1) Its parent 2) Its first child 3) Its first sibling, its previous sibling, the next sibling, and the last sibling.

Sooo

given any window handle, using cWinInfo to determine

a) Its immediate parent. If there is no parent, then it can deduce that it itself is a top level parent window of some sort.

b) It can find its oldest sibling, its previous and next siblings, and the youngest sibling. By starting with the oldest sibling, and getting the next sibling, then the next sibling and so on, it can make a list of all its brother and sister windows.

c) Its first child. By getting the first child, then that child's first sibling, it can make a list of all the child windows...and so on and so on.


Now, generally, cWndInfo is not used much.

In a Control Manager script, first you have to get a starting window handle. This is done via the cWndByWndSpec or the DllHwnd functions, which generally return a top level parent window handle of interest.

Soo. In addition to a window keeping track of its parent, siblings and children, a window also has 4 other features. Its title(or name), its class(type of window), its ID(a kind of identifying number) and its sequence number(where in the list of siblings that it appears)

and now once you have a the top level window handle for an application, you generally want to find a child window that is some obscure descendant of the toplevel parent window. So you must navigate to that window, generation by generation. the functions

cWndByName cWndByID cWndByClass and cWndBySeq

allow you to locate a particular child window of a parent window by any of 4 different ways. However not all of the ways will always work. Two windows might inexplicably have the same name, or ID, or Class. But at any given instant will always have different sequence numbers. However, at different instants, the sequence numbers may change...so cWndBySeq is only used as a last resort.

In any case one of the cWndByxxx functions will locate a particular child window for you.

Given that child window handle, then you can use another cWndByxxx to locate a particular grandchild window, and then the great-grandchild..and so on until the window of interest is eventually located.

If you use Roboscripter and examine the code it produces for you, you can see it using cWndByWndSpec to get the top level window handle, and then burrowing down to the desired window. This is RoboScripter's forte, relieving you of writing that code.

Ummm cWndInfo allows you to access any of that info.


Now ignore this part for now....

ANY window may also create a top level parent window, although this is rarely done. This is generally an "owned" window with its own separate hierarchy of children and grandchildren.

One example of this is doing FileOpen in Notepad. It creates a new window. This new window is a top level parent window only owned by the Notepad window, but otherwise having no relation to the notepad window. Most specifically it is not a child of any window in the base Notepad hierarchy.

Please note. Typos are left in as an exercise for the reader, although I'll try to at least spell check it


Article ID:   W16335
File Created: 2005:02:18:12:19:50
Last Updated: 2005:02:18:12:19:50