Reference » Window classes » MWindow » MWindow

Elgrint::MWindow::MWindow(MWindow&,MRect) method

Declaration (see MWindow.h):

MWindow(MWindow& parent, const MRect& rect);


Standard-form init constructor. Creates a new window using the specified parent, size, and position.


Name Type Description
parent MWindow&

The parent window of the new window. If parent is closed, the new window will not be opened (no error).

Details: Once the window is created, its parent cannot be changed, which is why this parameter is required during construction.

rect MRect

The initial size and position (including floating/embedded state) of the new window.

Details: The rect is rounded out to a nearest integral rect.
Once the window is created, the sign of z cannot be changed, which is why this parameter is required during construction.


This constructor is the only proper way of creating window objects and opening windows in Elgrint. Windows created by any other means (including MApp::messageBox) will not be part of the app's parent-child hierarchy and will not receive Elgrint messages. However, they will probably be able to coexist with the Elgrint windows.

The constructor generates a fatal error (which terminates the app) in the following situations:

The constructor generates exception 2001 (and aborts the construction) in the following situations:

The constructor generates a warning 3001 (but creates the new window) in the following situations:

If parent refers to a closed window or to a window which is in the process of being closed (after the call to close, but before the window actually closes), the constructor fails and does not open any window (because a closed window cannot have children). However, no error is generated in such a case, in accordance with the principle that all operations involving closed windows are silently ignored.

Otherwise, the constructor succeeds and creates a new window, whose parent is specified by parent. The parent of a window cannot be changed after the window has been created.

The new window is initially invisible. It becomes visible automatically as soon as the message loop starts or resumes (see runMessageLoop). The window can become visible sooner, if it is forcibly repainted (repaint is called with the repaintNow parameter set to true) or animated (setRect, setSize, or setPos is called with non-zero duration parameter). After becoming visible, the window remains visible until close is called. Elgrint provides no way of making existing window invisible, because it is not necessary. If you wish to hide a window, you can use setPos to move it beyond its parent's boundaries (preferably beyond the negative boundaries - this way it will remain hidden no matter how the parent is resized). MPageBar uses this method to switch between its pages. In any case, it is recommended to close and reopen windows instead of making them invisible, whenever practicable.

The rect parameter determines the initial size and position of the window (it does not have to be valid). The rect.z value determines whether the new window is embedded or floating. Embedded windows are clipped by their parents (i.e. only their parts which intersect the parent's window are visible), while floating windows are clipped only by the screen. In a sense, embedded children are located behind their parents (negative z coordinate), and floating children - in front of parents (positive z coordinate). If rect.z is positive, the newly created window is floating. If rect.z is negative, the newly created window is embedded. If z is 0 or invalid (e.g. Auto), the default state for the class is used (see constructor for each class). In most cases (including MWindow itself), the default state is embedded. Once a window is created, its floating/embedded state cannot be changed.

The parent and rect.z are the only two parameters of an Elgrint window, which cannot be changed after the window is created.

The new window inherits the RTL and the HighQuality properties from the parent.

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.