1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
class CFrameWnd, CMDIFrameWnd, CMDIChildWnd
The frame window classes represent a frame, a container for a view.
Frames are the borders of the view, and may have scroll bars, a header,
resizing controls etc. You can not draw in a frame, only in a view.
Each application must have one "Main" frame. Simple apps do not need
to derive a frame class and can just enter the base class in the
template (see app.txt).
In an SDI application, the Main and only frame is an instance of CFrameWnd. This
is set up in the template (see app.txt). The frame and its view
persist for the life of the application, and are simply reused when the
user selects File New or File Open.
In an MDI application, there is one Main frame derived from CMDIFrameWnd,
and zero or more instances of CMDIChildWnd. The CMDIFrameWnd object is used
as a container for the MDI child windows. It persists for the life of the
application. It has no view within it, and you can not draw in it.
It displays its own menu if there are no child windows, otherwise it displays
the menu of the active child. All drawing and document interaction are done
through the views in the CMDIChildWnd frames. These are created and destroyed
by the user, typically through the File Open, File New, and File Close menu items.
There may be any number of child windows, and the menu will typically have a
"Windows" item to rearrange, iconize, and tile the child windows.
You never create the frames which contain views yourself, since these are
created by document templates. See app.txt. So you never create your own
instances of CFrameWnd or CMDIChildWnd. But for an MDI app, you must create
the instance of CMDIFrameWnd yourself.
When frames and views are created by the template, the system uses the size
frame.wpySizeX and frame.wpySizeY and a default location. To control the
size of the frame, assign the size to wpySizeX/Y within your frame __init__()
method. Controling the location of the frame with frame.wpyLocX/Y
is not recommended. The size
can be changed later with frame.MoveWindowSize(). Do not alter the view
size, as this is controled by the frame size. Note that some window systems
may not honor window size requests. If you need to know the real size of
a frame or view, use GetClientRect() and GetWindowRect() instead of the
wpySizeX/Y for the window.
The title for an SDI app is a base title CWinApp::wpyMainTitle plus the
document title. For the MDI frame window, the title is its wpyText.
For MDI child windows the title is the document title plus the
file name if any. If there are multiple views, a number 1, 2, 3, ... is
added.
class CFrameWnd(CWnd)
Instance Variables
wpyText
Header text for the frame.
wpyParent
For a frame, the parent is the document.
wpyChildList
For a frame, the child list is a list of views.
wpyStatusLine
To create a frame with a status line, set this to an instance
of CStatusBar (see below) within __init__(). When the frame is created
the status line will be created too.
Methods
__init__(self, templ, doc)
templ: The template being used to create the frame.
doc: The document which creates the frame.
The framework creates frames as required. The user never constructs
a frame directly, except for a CMDIFrameWnd.
GetActiveDocument(self)
Return the active document.
GetActiveView(self)
Return the active view.
RecalcLayout(self)
Recalculate the size of the view, status line, etc. within the frame.
For internal use only.
Messages
OnCreate(self, not_used)
Sent to the frame soon after it is created. This is always the
first message sent to a frame.
OnDestroy(self)
Sent to the frame before it is destroyed.
OnSize(self, new_size)
Sent after "OnCreate" when a window is created, or when the user or system
changes the window size.
class CMDIFrameWnd(CFrameWnd)
Instance Variables
wpyParent
The parent is the app instance.
wpyWindowList
A list of all MDI child windows within this frame window.
wpyText
Use to set a title for the window when it is created.
Methods
__init__(self)
Create(self)
Create an instance of CMDIFrameWnd.
class CMDIChildWnd(CFrameWnd)
Methods
__init__(self, templ, doc)
templ: The template being used to create the frame.
doc: The document which creates the frame.
The framework creates frames as required. The user never constructs
a frame directly, except for a CMDIFrameWnd.
class CStatusBar
The CStatusBar object represents a status bar to be displayed at the bottom
of a frame. To create a status bar, set the frame attribute wpyStatusLine to
an instance of this class as follows:
self.wpyStatusLine = CStatusBar(self, "Initial text")
Methods
SetPaneText(self, index, text, update = 1)
Set the text in pane "index" 0, 1, 2, ... to "text". If update is true,
invalidate the window. Currently only one pane is supported, so
index must be 0.
SetWindowText(self, text)
SetWindowText(self, text) is equivalent to SetPaneText(self, 0, text, 1).
|