Description

Sets or reveals the position of the main application window or optionally a given window.

Property type

A Variant value.  

Syntax

object.WindowPosition([WindowNameOrID]) [= value]

The WindowPosition Property 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 application's top level window is being referenced.

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 is used. Next if the caption of any top level window matches the argument up to the length of the argument, then that window is used. Lastly, the name is used as an McWindow.Name property to do a look up in the Windows collection for a McWindow object. All string comparisons are case-insensitive.

If the argument is given as an McWindow object, then that MDI child window is used. However, note that for clarity it is preferable to use the McWindow.Position property to position and size McWindow object's MDI window.

Finally the argument can be a scalar numeric value, previously returned from FindWindow (see Example 4).

valueA Variant value.

Remarks

This property will be exposed as either a single scalar value that is one of the mcWindowPosition constants (mcwpMinimize if the window is minimized or mcwpMaximize) or as a LONGRECT (whenever the window is not maximized or minimized). Use the IsNumeric VB method to test for the single scalar value (see Example 4).

When exposed as a LONGRECT the values are the position rectangle of the window. The right, bottom coordinate is the pixel just past the rightmost, bottommost one occupied by the window (that is right minus left is the width of the window in screen pixels).

Coordinates of all top level windows (including popup dialogs) are exposed in coordinates relative to the upper left of the screen ("screen coordinates"). Coordinates of child windows (such as any McWindow object's MDI child window) are given relative to the upper left of their parent window's client area ("client coordinates"). The same rules apply on assignment, so coordinates returned from WindowPosition can later be assigned to achieve the same window postion.

On assignment, the assigning Variant can be a single scalar value that is one of the mcWindowPosition constants, or it can be a LONGPOINT or a length-2 array, or it can be a LONGRECT or a length-4 array.

If assigned a single scalar value, then mcwpMinimize will minimize the window, mcwpMaximize will maximize the window and mcwpRestore will restore it to its normal (un-minimized and un-maximized) position.

If assigned a LONGPOINT or a length-2 array then the window is first restored to its normal state if it is minimized or maximized, and then the left,top of the window is moved to the given x,y position, with its size left unchanged. Top level windows expect “screen coordinates” while child windows use "client coordinates".

If assigned a LONGRECT or a length-4 array then the window is first restored to its normal state if it is minimized or maximized, and then the window is moved and sized to the given left, top, right, bottom position. The right, bottom coordinate is the pixel just past the rightmost, bottommost one to be occupied by the window (that is right minus left is the width of the window in screen pixels) Top level windows expect “screen coordinates” while child windows use “client coordinates”.

Exceptions

If given, the WindowNameOrID must reference a legal, visible window (use FindWindow if you need to check; see Example 4).