Reference » Window classes » MWindow » getRect

Elgrint::MWindow::getRect() method

Declaration (see MWindow.h):

MRect getRect();

Description

Returns the current size and position of the window, including floating/embedded state.

Return type: MRect

Details

The position (x,y,z) of the window is always relative to the top-left corner of the window's parent. The size (w,h,d) does not depend on the origin of the coordinates, of course (size is an absolute characteristic).

The x, y, w, and h coordinates are always expressed in pixels. The d coordinate is always 1 (reserved for the future support of 3D windows). The z coordinate is +1 for a floating window (the one "in front of" its parent), -1 for an embedded window (the one "behind" its parent), and 0 for MScreen and closed windows (these are their own parents, so they cannot be in front of or behind themselves).

If the window is closed, the function returns MRect(0,0,0,1,1,1), which is safer than NoneRect or ZeroRect (prevents accidental overflow or division by 0).

When a new window is created, its size and position (including floating/embedded state) are determined by the rect parameter of the MWindow::MWindow constructor, but technically, they are undefined until the window is finalized. Finalizing is meaningless until the object is fully constructed and its virtual table (i.e. the list of handlers, including the crucial OnRectChanging) is complete, so the window cannot be finalized in the MWindow constructor.

On the other hand, getRect is often called right after the construction (or even during one). Therefore, if getRect is called before the window is finalized, it is partially finalized on the spot (without showing the window, though), before getRect returns. In particular, this means that calling getRect may generate RectChanging message. That being said, this behavior is usually transparent to both the user and the developer.

The getRect is also a part of the "missing repaint" detection mechanism (see Resized).

Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.