wxFrame: wxWindow

A frame is a window which contains subwindows of various kinds. It has a title bar and, optionally, a menu bar, and a status line. Depending on the platform, the frame has further menus or buttons relating to window movement, sizing, closing, etc. Most of these events are handled by the host system without need for special handling by the application. However, the application should normally define an OnClose handler for the frame so that related data and subwindows can be cleaned up.

The Windows 3 issues of Multiple Document Interface (MDI) versus Single Document Interface (SDI) frames are covered in section [*] and in the tutorial.

wxFrame::wxFrame

voidwxFramewxFrame *parent, char *title, int x = -1, int y = -1,
int width = -1, int height = -1, int style = wxSDI

Constructor. The parent parameter can be NULL or an existing frame. The final parameter determines whether, under Windows, the frame is an SDI frame (wxSDI), an MDI parent frame (wxMDI_PARENT) or an MDI child frame (wxMDI_CHILD).

wxFrame::wxFrame

voidwxFrame

Destructor. Destroys all child windows and menu bar if present.

wxFrame::Centre

voidCentreint direction = wxBOTH

Centres the frame on the display. The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.

wxFrame::CreateStatusLine

voidCreateStatusLine

Creates a status line at the bottom of the frame. The width of the status line is the whole width of the frame (adjusted automatically when resizing), and the height and text size are chosen by the host system. Does not work for MDI parent frames.

wxFrame::Iconize

voidIconizeBool iconize

If TRUE, iconizes the frame; if FALSE, shows and restores it.

wxFrame::Iconized

BoolIconized

Returns TRUE if the frame is iconized.

wxFrame::OnMenuCommand

voidOnMenuCommandint id

Sent to the window when an item on the window's menu has been chosen. Derive your own frame class to handle this message.

wxFrame::OnMenuSelect

voidOnMenuSelectint id

Sent to the window when an item on the window's menu has been selected (i.e. the cursor is on the item, but the left button has not been released). Derive your own frame class to handle this message. See the hello sample for an example of using this to implement a line of explanation about each menu item.

This function is only called under Windows 3.

wxFrame::SetIcon

voidSetIconwxIcon * icon

Sets the icon for this frame, deleting any existing one. Note an important difference between XView and Windows 3 behaviour. In Windows 3, the title of the frame is the icon label, wrapping if necessary for a long title. If the frame title changes, the icon label changes. In XView, the icon label cannot be changed once the icon has been associated with the frame. Also, there is no wrapping, and icon labels must therefore be short.

The best thing to do to accommodate both situations is to have the frame title set to a short string when setting the icon. Then, set the frame title to the desired text. In XView, the icon will keep its short text. In Windows 3, the longer (probably more meaningful) title will be shown.

Note also that in Windows 3, icons cannot be associated with a window after window initialization, except by explicitly drawing the icon onto the iconized window, which is what wxWindows does. Because of this workaround, the background of the icon will be white rather than the usual transparent. It was felt limiting to have to pass an icon name at frame create time.

However, drawing the icon like this does not work (for some unknown reason) with MDI parent and child frames, and so for MDI applications the following lines need to be added to the Windows 3 resource file:

wxSTD_FRAME         ICON icon1.ico
wxSTD_MDICHILDFRAME ICON icon2.ico

where icon1.ico will be used for SDI frames or the MDI parent frame, and icon2.ico will be used for MDI child frames.

wxFrame::SetMenuBar

voidSetMenuBarwxMenuBar *frame

Tells the frame to show the given menu bar. If the frame is destroyed, the menu bar and its menus will be destroyed also, so do not delete the menu bar explicitly (except by resetting the frame's menu bar to another frame or NULL).

wxFrame::SetStatusText

voidSetStatusTextchar * text

Sets the status line text and redraws the status line. Use an empty (not NULL) string to clear the status line.

wxFrame::StatusLineExists

BoolStatusLineExists

Returns TRUE if the status line has previously been created.