Wiki Home

WCHILD


Namespace: WIN_COM_API
Returns either the number of child windows in a parent window or the names of the child windows in the order in which they are stacked in the parent window.

WCHILD([WindowName] [nChildWindow])

Parameters
WindowName
Specifies a window other than the active output window for which WCHILD( ) returns the number of child windows. The number of child windows in the specified window is returned if you include just a window name without the numeric expression nChildWindow.

If you include both WindowName and nChildWindow, WCHILD( ) returns the names of the child windows in the specified window. If you include both WindowName and nChildWindow, separate WindowName and nChildWindow with a comma.

You can also include the empty string in WindowName to specify the main Visual FoxPro window.

nChildWindow
Specifies a numeric expression included to return the names of child windows in the active output window when you omit WindowName.

The numeric expression nChildWindow can be 0 or any positive value. The name of the child window at the bottom of the stack of child windows in the current output window is returned if nChildWindow is 0.

If nChildWindow is a positive number, WCHILD( ) returns the name of the next child window in the window stack. The name of next child window in the stack is returned if you issue WCHILD( ) again with a positive number, and so on. The empty string is returned if WCHILD( ) is called more times than the number of child windows in the parent window. For more information on window stacking, see ACTIVATE WINDOW.

Example:
lc_windowlist = ""
lcWindName = WCHILD("",0) && The "" must be a NULL or empty string

* Loop through all open forms, and see if we have any that have the same
* name as the one you want to open. (It exists in INIT() but is not yet
* available.)

* Gather a list of open windows
DO WHILE !EMPTY(lcWindName)
  * Skip if you want VFP windows: COMMAND is command window under VFP / programmer
  *              Bckgrnd is map image  standard is default toolbar
        IF atc( lcWindName , "COMMAND;BCKGRND;STANDARD") = 0
    lc_windowlist = lc_windowlist + "    " + lcWindName + chr(13)  && chr(13) is C/R
  ENDIF
  lcWindName = WCHILD("",1) && The "" must be a NULL or empty string
ENDDO
** do something with the list
...


Contributor: Craig Roberts
( Topic last updated: 2010.08.09 10:11:09 PM )