void AFXAPI AfxOleOnReleaseAllObjects() { // don't shut down the application if user is in control of the app if (AfxOleGetUserCtrl()) return; AfxOleSetUserCtrl(TRUE); // avoid re-entry // shut down the application CWinApp* pApp = AfxGetApp(); ASSERT_VALID(pApp); if (pApp->m_pMainWnd != NULL) { // destroy the main window (only if enabled) if (pApp->m_pMainWnd->IsWindowEnabled()) { // the main window will post WM_QUIT as part of its shutdown pApp->m_pMainWnd->DestroyWindow(); } } else if (!afxContextIsDLL) { // no main window, so just post WM_QUIT. AfxPostQuitMessage(0); } }
// @pymethod int|win32uiole|OleGetUserCtrl|Returns the application name. static PyObject * win32uiole_get_user_ctrl(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args,":OleGetUserCtrl")) return NULL; GUI_BGN_SAVE; int rc = AfxOleGetUserCtrl(); GUI_END_SAVE; return Py_BuildValue("i", rc); }
CCmdTarget* COleTemplateServer::OnCreateObject() { ASSERT_VALID(this); ASSERT_VALID(m_pDocTemplate); // save application user control status BOOL bUserCtrl = AfxOleGetUserCtrl(); // create invisible doc/view/frame set CDocument* pDoc = m_pDocTemplate->OpenDocumentFile(NULL, FALSE); // restore application's user control status AfxOleSetUserCtrl(bUserCtrl); if (pDoc != NULL) { ASSERT_VALID(pDoc); ASSERT_KINDOF(CDocument, pDoc); // all new documents created by OLE start out modified pDoc->SetModifiedFlag(); } return pDoc; }