From WxWiki
Jump to: navigation, search
Official Classes SmallBlocks.png Archive Containers Controls Data Structures Database Date & Time Debug Device Contexts Dialogs Document & Views Drag & Drop Events Filesystem Frames Graphics Grid Cell Help HTML Logging Miscellaneous Networking Printing Sizers Streams Threading Windows

A frame is a window whose size and position can (usually) be changed by the user.

It usually has thick borders and a title bar, and can optionally contain a menu bar, toolbar and status bar. A frame can contain any window that is not a frame or dialog.

A frame that has a status bar and toolbar, created via the CreateStatusBar() and CreateToolBar() functions, manages these windows and adjusts the value returned by GetClientSize() to reflect the remaining size available to application windows.

Note: An application should normally define an wxCloseEvent handler for the frame to respond to system close events, for example so that related data and subwindows can be cleaned up.

To minimize a frame, use wxTopLevelWindow::Iconize.


Why doesn't my wxFrame receive initial OnPaint events?

If your wxFrame doesn't receive the initial OnPaint event but receives all others, make sure that wxFrame::Show() is called after all children have been added to the frame. If you try to add a wxWindow to the frame after it has already been shown, weird things may happen.

Even if I don't call "Show" during OnInit, my frame is visible

It seems that Win32 will always show your frame even if you don't want it. Doing this will help you to get the required behaviour :

bool MyApp::OnInit()
    MyFrame * mainFrame = new MyFrame(........);
    mainFrame->Show(true); // the wxFrame doesn't know that it is visible : we have to tell it !
    mainFrame->Show(false); // doing this, the frame will only be visible as a remanent image (only on slow computers)
    return true;

Segmentation fault during my frame construction

Perhaps you are receiving OnSize (and other) events before having left the frame constructor. This is why you must be particulary careful when managing these events. See the previous question.

See Also