MCPcopy Create free account
hub / github.com/mhammond/pywin32 / PyCView_create_window

Function PyCView_create_window

Pythonwin/win32view.cpp:90–140  ·  view source on GitHub ↗

@pymethod |PyCView|CreateWindow|Creates the window for a view.

Source from the content-addressed store, hash-verified

88
89// @pymethod |PyCView|CreateWindow|Creates the window for a view.
90static PyObject *
91PyCView_create_window(PyObject *self, PyObject *args)
92{
93 CView *pView = PyCView::GetViewPtr(self);
94 if (!pView) {
95 // PyCView::GetViewPtr will trace to the debug device - just so I know it is an OK one!
96 TRACE(" ignore warning - RTTI Error detected and handled!");
97 PyErr_Clear();
98 pView = GetEditViewPtr(self);
99 }
100 if (!pView)
101 return NULL;
102
103 if (pView->m_hWnd!=NULL)
104 RETURN_ERR("The view already has a window");
105
106 PyObject *parent;
107 int id= AFX_IDW_PANE_FIRST;
108 int style= AFX_WS_DEFAULT_VIEW;
109 CRect rect(0,0,0,0);
110 if (!PyArg_ParseTuple(args, "O|ii(iiii):CreateWindow",
111 &parent, // @pyparm <o PyCWnd>|parent||The parent window (usually a frame)
112 &id, // @pyparm int|id|win32ui.AFX_IDW_PANE_FIRST|The child ID for the view
113 &style, // @pyparm int|style|win32ui.AFX_WS_DEFAULT_VIEW|The style for the view
114 // @pyparm (left, top, right, bottom)|rect|(0,0,0,0)|The default position of the window.
115 &rect.left, &rect.top, &rect.right, &rect.bottom))
116 return NULL;
117
118 if (!ui_base_class::is_uiobject(parent, &PyCWnd::type))
119 RETURN_TYPE_ERR("Argument must be a PyCWnd");
120 CWnd *pWnd = GetWndPtr( parent );
121 if (pWnd==NULL)
122 return NULL;
123
124 CCreateContext context;
125 GUI_BGN_SAVE;
126 context.m_pCurrentDoc = pView->GetDocument();
127// if (!context.m_pCurrentDoc)
128// RETURN_ERR("There is no document attached to the view");
129
130 // must reset doc to NULL, else MFC asserts all over the place!
131 // Create() resets this value (via the CreateContext)
132 ((CProtectedView *)pView)->SetDocument( NULL );
133
134 BOOL ok;
135 ok = pView->Create(NULL, NULL, style, rect, pWnd, id, &context);
136 GUI_END_SAVE;
137 if (!ok)
138 RETURN_ERR("Create() view failed\n");
139 RETURN_NONE;
140}
141
142// @pymethod <o PyCDocument>|PyCView|GetDocument|Returns the document for a view.
143static PyObject *

Callers

nothing calls this directly

Calls 5

GetEditViewPtrFunction · 0.85
GetWndPtrFunction · 0.85
GetDocumentMethod · 0.45
SetDocumentMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected