Description

Finds a window “handle” if the window exists

Return Type

A Long value.  

Zero if the window could not be found or was not a valid window. Otherwise, a “window handle” to the window is returned, which may be supplied as an argument to methods that accept such “window handles”.

Syntax

object.FindWindow ([WindowNameOrID])

The FindWindow Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McApplication.
WindowNameOrIDOptional. A Variant value.

This may be empty or missing, a string window title name, a string name of an McWindow iLPn the Windows collection, an McWindow object or a scalar “window handle” value.

If the argument is missing or empty (the default), then the “window handle” of the application's top level window is returned.

If the argument is a string, several tests are performed. If the caption of any top level window (including popups) exactly matches the string, then that window's handle is returned. Next if the caption of any top level window matches the argument up to the length of the argument, then that window handle is returned. Finally, the name used as an McWindow.Name property to do a look up in the Windows collection. All string comparisons are case-insensitive.

If the argument is given as an McWindow object, then the window handle of that MDI child window is returned.

Finally if the argument is given as a scalar numeric value, then if that value is a legal window handle it is returned, otherwise 0 is returned. This allows you to test whether a value previously returned from FindWindow refers to a window that is still open.

Remarks

This method can determine if a given window is currently open and visible, and if so, it will return a “handle” which may may be supplied as an argument to methods that accept such “window handles” (e.g., the WindowPosition property).