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 142 143 144 145 146 147 148 149 150 151 152 153 154
|
class CWnd
Class CWnd is the parent class for visible objects. This is where common
methods are defined. Currently CWnd is not instantiated as an object.
Methods
DestroyWindow(self)
Destroy the GUI window. This is used for controls to get rid of
the control. Do not call this for frames and views, because these
objects are managed by the framework.
EnableWindow(self, enabled)
Bool enabled
Make a control enabled or disabled. Return the previous state
of the control. Disabled controls appear grayed out, and do not
respond to user actions.
GetClientRect(self)
Return a CRect rectangle giving the size of the client area of the
object. The location is (0, 0).
GetWindowRect(self)
Return a CRect rectangle giving the size and location of
the window on the screen.
GetDC(self)
ReleaseDC(self, DC)
Return the device context for this window. You MUST call ReleaseDC()
before you exit from the function from which GetDC() is called, as the
object returned is volatile. These functions are only used for drawing
with the mouse. Normal drawing to a view is handled in OnDraw(self, DC).
GetWindowText(self)
SetWindowText(self, text)
text, a string
Set or return the "text" in the window. This is the window title,
control text, or other text depending on the type of window. All
windows have text, even if it is not visible. GetWindowText is
really only used for windows with variable text, such as CEdit
controls. Fixed text is available as self.wpyText. SetWindowText
is only used to change text after the window is created. Before the
window is created, you can assign to self.wpyText. Do not use
SetWindowText to set text for frame windows, as these are set
from the document title.
GetTextExtent(self, text)
string text
Return the size of the text as the tuple (width, height). Needed to
do text layout and drawing. This method really applies to a device
context. When called for a window, it uses the window's device
context. Within view::OnDraw(), you must call with the device
context given, as "DC.GetTextExtent()".
InvalidateRect(self)
Called for a view to inform the system that the view is invalid and
must be redrawn. This will result in an OnDraw() message at an
indeterminate time in the future, probably when the system is otherwise
idle. This is how you redraw a view. You must never call OnDraw()
directly.
MoveWindow(self)
Notify the system of new values for self.wpyLocX/Y and
self.wpySizeX/Y. Used when you want to move the window
after you have created it.
MoveWindowLoc(self)
Like MoveWindow(), but only changes the location, not the size.
MoveWindowSize(self)
Like MoveWindow(), but only changes the size, not the location.
MoveWindowTop(self)
Move window to the top of the Z order. Not valid for Tk.
MoveWindowBottom(self)
Move window to the bottom of the Z order. Not valid for Tk.
SetCapture(self)
GetCapture()
ReleaseCapture()
Use SetCapture to capture (grab) mouse events for this window. Needed
when drawing with the mouse to prevent the system from sending mouse events
to a different window. You must call ReleaseCapture() to release the capture
when you are done. Call GetCapture to return the window which has capture
or None. Note that GetCapture and ReleaseCapture are global functions, not
methods. SetCapture is a method.
SetFocus(self)
Set the focus to this window. Return the window which used to have
focus, or None.
SetFont(self, font, redraw = 1)
font, a CFont font object
redraw, boolean, whether to redraw the window
Set the font for the window. For example, you could change a CEditView
window to use a fixed pitch font.
ShowWindow(self, show)
boolean show
Show or hide the window. Return the previous window status.
Messages
These are the messages which may be sent to a window. Recall that many messages
from controls are sent to the parent window of the control. Not all these
messages will be sent to every window, as the valid messages depend on the window.
OnLButtonDown(self, x, y, flags)
OnLButtonUp(self, x, y, flags)
OnLButtonDblClk(self, x, y, flags)
OnRButtonDown(self, x, y, flags)
OnRButtonUp(self, x, y, flags)
OnRButtonDblClk(self, x, y, flags)
OnMouseMove(self, x, y, flags)
x, y, the position if the mouse cursor
flags, the status of the shift and control keys, and the mouse buttons
These messages are sent when the user operates the mouse. Mouse move
messages are normally not sent unless a mouse button is pressed or
a relevant key is pressed (flags non-zero).
OnListBox(self, control)
Sent when an item in a list box is selected.
OnListBoxDbl(self, control)
Sent when the user double clicks an item in a list box.
OnCreate(self, event)
The window was just created. This is the first message a window receives.
OnDestroy(self)
The window is about to be destroyed.
OnHScroll(self, event)
OnVScroll(self, event)
The window's scroll bar was operated.
OnScroll(self, control)
control, a CScrollBar object
A scroll bar control (not the window's own scroll bar) was operated.
OnSize(self, rect)
CRect object rect
The window was newly created or was resized. Sent soon after OnCreate
or in response to a resize. The client size of the window is "rect",
and you normally do layout relative to "rect".
OnSysCommand(self, nID, lParam) ** Windows Only **
nID: Int, one of the SC_* constants in wpycon.py.
lParam: See your MFC documentation.
Sent to the frame when the user selects an item from the system
menu, the menu box in the window frame. Normally, the default
system action is called. To skip the default call, return zero.
This message is only sent to frame windows.
|