BOOL DoInit() { HINSTANCE hInstance = g_Instance; int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); // AFX internal initialization if (!AfxWinInit(hInstance, NULL, TEXT(""), SW_SHOW)) return DoExit(); // App global initializations (rare) if (pApp != NULL && !pApp->InitApplication()) return DoExit(); // Perform specific initializations if (!pThread->InitInstance()) { if (pThread->m_pMainWnd != NULL) { TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } nReturnCode = pThread->ExitInstance(); return DoExit(); } return TRUE; }
//------------------------------------------------------------------ // main //------------------------------------------------------------------ void main() { CWinApp* pApp = AfxGetApp(); pApp->InitApplication(); pApp->InitInstance(); pApp->Run(); CMyDoc* pMyDoc = new CMyDoc; CMyView* pMyView = new CMyView; CFrameWnd* pMyFrame = (CFrameWnd*)pApp->m_pMainWnd; // output Message Map construction AFX_MSGMAP* pMessageMap = pMyView->GetMessageMap(); cout << endl << "CMyView Message Map : " << endl; MsgMapPrinting(pMessageMap); pMessageMap = pMyDoc->GetMessageMap(); cout << endl << "CMyDoc Message Map : " << endl; MsgMapPrinting(pMessageMap); pMessageMap = pMyFrame->GetMessageMap(); cout << endl << "CMyFrameWnd Message Map : " << endl; MsgMapPrinting(pMessageMap); pMessageMap = pApp->GetMessageMap(); cout << endl << "CMyWinApp Message Map : " << endl; MsgMapPrinting(pMessageMap); }
int main(void) { CWinApp* pApp = AfxGetApp(); pApp->InitApplication(); pApp->InitInstance(); pApp->Run(); CMyDoc* pMyDoc = new CMyDoc; CMyView* pMyView = new CMyView; CFrameWnd* pMyFrame = (CFrameWnd*)pApp->m_pMainWnd; pMyFrame->m_pViewActive = pMyView; pMyView->m_pDocument = pMyDoc; std::cout << std::endl << "pMyFrame received a WM_CREATE, routing path : " << std::endl; AfxWndProc(0, WM_CREATE, 0, 0, pMyFrame); std::cout << std::endl << "pMyView received a WM_COMMAND, routing path : " << std::endl; AfxWndProc(0, WM_COMMAND, 0, 0, pMyView); std::cout << std::endl << "pMyFrame received a WM_COMMAND, routing path : " << std::endl; AfxWndProc(0, WM_COMMAND, 0, 0, pMyFrame); system("pause"); return 0; }
//------------------------------------------------------------------ // main //------------------------------------------------------------------ void main() { CWinApp* pApp = AfxGetApp(); pApp->InitApplication(); pApp->InitInstance(); pApp->Run(); CMyDoc* pMyDoc = new CMyDoc; CMyView* pMyView = new CMyView; CWnd* pMyWnd = pApp->m_pMainWnd; cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CMyDoc)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CMyDoc)) << "\n"; cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CDocument)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CDocument)) << "\n"; cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CCmdTarget)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CCmdTarget)) << "\n"; cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CObject)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CObject)) << "\n"; cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CWinApp)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CWinApp)) << "\n"; cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CView)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CView)) << "\n"; cout << "pMyView->IsKindOf(RUNTIME_CLASS(CView)) " << pMyView->IsKindOf(RUNTIME_CLASS(CView)) << "\n"; cout << "pMyView->IsKindOf(RUNTIME_CLASS(CObject)) " << pMyView->IsKindOf(RUNTIME_CLASS(CObject)) << "\n"; cout << "pMyView->IsKindOf(RUNTIME_CLASS(CWnd)) " << pMyView->IsKindOf(RUNTIME_CLASS(CWnd)) << "\n"; cout << "pMyView->IsKindOf(RUNTIME_CLASS(CFrameWnd)) " << pMyView->IsKindOf(RUNTIME_CLASS(CFrameWnd)) << "\n"; cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)) " << pMyWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)) << "\n"; cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CWnd)) " << pMyWnd->IsKindOf(RUNTIME_CLASS(CWnd)) << "\n"; cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CObject)) " << pMyWnd->IsKindOf(RUNTIME_CLASS(CObject)) << "\n"; cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CDocument)) " << pMyWnd->IsKindOf(RUNTIME_CLASS(CDocument)) << "\n"; }
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ASSERT(hPrevInstance == NULL); int nReturnCode = -1; __try { CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); // AFX internal initialization if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; // App global initializations (rare) if (pApp != NULL && !pApp->InitApplication()) goto InitFailure; // Perform specific initializations if (!pThread->InitInstance()) { if (pThread->m_pMainWnd != NULL) { TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } nReturnCode = pThread->ExitInstance(); goto InitFailure; } nReturnCode = pThread->Run(); InitFailure: #ifdef _DEBUG // Check for missing AfxLockTempMap calls if (AfxGetModuleThreadState()->m_nTempMapLock != 0) { TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock); } AfxLockTempMaps(); AfxUnlockTempMaps(-1); #else ; #endif } __except(RecordExceptionInfo(GetExceptionInformation())) { } // must call AfxWinTerm after handling exception or we'll crash // again trying to destroy the tooltip window AfxWinTerm(); return nReturnCode; }
void main() { CWinApp *pApp = AfxGetApp(); pApp->InitApplication(); pApp->InitInstance(); pApp->Run(); PrintAllClasses(); }
int main() { cout << "main 開始執行" << endl; CWinApp* pApp = AfxGetApp(); pApp->InitApplication(); //CWinApp::InitApplication pApp->InitInstance(); //CMyWinApp::InitInstance --> CMyFrameWnd pApp->Run(); //CwinApp::Run cout << "main 結束執行" << endl; return 0; }
extern "C" int WINAPI #endif WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { ASSERT(hPrevInstance == NULL); lpCmdLine; int nReturnCode = -1; CWinApp* pApp = AfxGetApp(); // AFX internal initialization LPTSTR p = GetCommandLine(); while (*p && (*p != _T(' '))) p++; if (*p) p++; if (!AfxWinInit(hInstance, hPrevInstance, p, nCmdShow)) goto InitFailure; // App global initializations (rare) ASSERT_VALID(pApp); if (!pApp->InitApplication()) goto InitFailure; ASSERT_VALID(pApp); // Perform specific initializations if (!pApp->InitInstance()) { if (pApp->m_pMainWnd != NULL) { TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); pApp->m_pMainWnd->DestroyWindow(); } nReturnCode = pApp->ExitInstance(); goto InitFailure; } ASSERT_VALID(pApp); nReturnCode = pApp->Run(); ASSERT_VALID(pApp); InitFailure: AfxWinTerm(); return nReturnCode; }
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ASSERT(hPrevInstance == NULL); int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); // AFX internal initialization bool InitSuccess = AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow); // App global initializations (rare) if (pApp != NULL) InitSuccess = InitSuccess && pApp->InitApplication(); // Perform specific initializations InitSuccess = InitSuccess && pThread->InitInstance(); // Run the BCI2000 core module. if( InitSuccess ) { CoreModuleMFC coreModule; nReturnCode = ( coreModule.Run( __argc, __argv ) ? 0 : -1 ); } else { if (pThread->m_pMainWnd != NULL) { TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } } pThread->ExitInstance(); #ifdef _DEBUG // Check for missing AfxLockTempMap calls if (AfxGetModuleThreadState()->m_nTempMapLock != 0) { TRACE1("Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock); } AfxLockTempMaps(); AfxUnlockTempMaps(-1); #endif AfxWinTerm(); return nReturnCode; }
/* ================= RadiantInit This is also called when you 'quit' in doom ================= */ void RadiantInit( void ) { // make sure the renderer is initialized if ( !renderSystem->IsOpenGLRunning() ) { common->Printf( "no OpenGL running\n" ); return; } g_editorAlive = true; // allocate a renderWorld and a soundWorld if ( g_qeglobals.rw == NULL ) { g_qeglobals.rw = renderSystem->AllocRenderWorld(); g_qeglobals.rw->InitFromMap( NULL ); } if ( g_qeglobals.sw == NULL ) { g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw ); } if ( g_DoomInstance ) { if ( ::IsWindowVisible( win32.hWnd ) ) { ::ShowWindow( win32.hWnd, SW_HIDE ); g_pParentWnd->ShowWindow( SW_SHOW ); g_pParentWnd->SetFocus(); } } else { Sys_GrabMouseCursor( false ); g_DoomInstance = win32.hInstance; CWinApp* pApp = AfxGetApp(); CWinThread *pThread = AfxGetThread(); InitAfx(); // App global initializations (rare) pApp->InitApplication(); // Perform specific initializations pThread->InitInstance(); qglFinish(); //qwglMakeCurrent(0, 0); qwglMakeCurrent(win32.hDC, win32.hGLRC); // hide the doom window by default ::ShowWindow( win32.hWnd, SW_HIDE ); } }
/* ================= RadiantInit This is also called when you 'quit' in doom ================= */ void RadiantInit( void ) { // make sure the renderer is initialized if ( !renderSystem->IsOpenGLRunning() ) { common->Printf( "no OpenGL running\n" ); return; } g_editorAlive = true; // allocate a renderWorld and a soundWorld if ( g_qeglobals.rw == NULL ) { // jmarshall // g_qeglobals.defaultEditorMaterial = declManager->FindMaterial( "_editordefault" ); RadiantInitTestWindow(); // jmarshall end g_qeglobals.rw = renderSystem->AllocRenderWorld(); g_qeglobals.rw->InitFromMap( NULL ); } if ( g_qeglobals.sw == NULL ) { g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw ); } if ( g_DoomInstance ) { if ( ::IsWindowVisible( win32.hWnd ) ) { ::ShowWindow( win32.hWnd, SW_HIDE ); g_pParentWnd->ShowWindow( SW_SHOW ); g_pParentWnd->SetFocus(); } } else { sys->GrabMouseCursor( false ); g_DoomInstance = win32.hInstance; CWinApp* pApp = AfxGetApp(); CWinThread *pThread = AfxGetThread(); InitAfx(); // App global initializations (rare) pApp->InitApplication(); // Perform specific initializations pThread->InitInstance(); qglFinish(); //qwglMakeCurrent(0, 0); renderDevice->BindDeviceToWindow(win32.hDC); // hide the doom window by default ::ShowWindow( win32.hWnd, SW_HIDE ); // jmarshall toolInterfaceLocal.ShowDebugConsole(); // jmarshall end } }
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { char szLogFileName[_MAX_DIR]; if (GetRecommandLogFileName(szLogFileName) == false) return FALSE; InitLog(MLOGSTYLE_DEBUGSTRING|MLOGSTYLE_FILE, szLogFileName); // Wrap WinMain in a structured exception handler (different from C++ // exception handling) in order to make sure that all access violations // and other exceptions are displayed - regardless of when they happen. // This should be done for each thread, if at all possible, so that exceptions // will be reliably caught, even inside the debugger. #ifdef SUPPORT_EXCEPTIONHANDLING char szDumpFileName[_MAX_DIR]; strcpy(szDumpFileName, szLogFileName); strcat(szDumpFileName, ".dmp"); __try { #endif // The code inside the __try block is the MFC version of AfxWinMain(), // copied verbatim from the MFC source code. ASSERT(hPrevInstance == NULL); int nReturnCode = -1; CWinApp* pApp = AfxGetApp(); // AFX internal initialization if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; // App global initializations (rare) ASSERT_VALID(pApp); if (!pApp->InitApplication()) goto InitFailure; ASSERT_VALID(pApp); // Perform specific initializations if (!pApp->InitInstance()) { if (pApp->m_pMainWnd != NULL) { TRACE(_T("Warning: Destroying non-NULL m_pMainWnd\n")); pApp->m_pMainWnd->DestroyWindow(); } nReturnCode = pApp->ExitInstance(); goto InitFailure; } ASSERT_VALID(pApp); nReturnCode = pApp->Run(); ASSERT_VALID(pApp); InitFailure: #ifdef _DEBUG // Check for missing AfxLockTempMap calls if (AfxGetModuleThreadState()->m_nTempMapLock != 0) { TRACE(_T("Warning: Temp map lock count non-zero (%ld).\n"), AfxGetModuleThreadState()->m_nTempMapLock); } AfxLockTempMaps(); AfxUnlockTempMaps(-1); #endif AfxWinTerm(); return nReturnCode; #ifdef SUPPORT_EXCEPTIONHANDLING } // __except(MFilterException(GetExceptionInformation())){ __except(CrashExceptionDump(GetExceptionInformation(), szDumpFileName)){ // char szFileName[_MAX_DIR]; // GetModuleFileName(NULL, szFileName, _MAX_DIR); // WinExec(szFileName, SW_SHOW); // Launch again //MMatchServer::GetInstance()->CheckMemoryTest(); //MGetServerStatusSingleton()->Dump(); } #endif return 0; }
int AFXAPI AfxWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { #ifdef DISPLAYCONSOLE // Redirection of standard output to console int hCrt; BOOL rep; FILE *hf; _SYSTEM_INFO lps; GetSystemInfo(&lps); rep = AllocConsole(); hCrt = _open_osfhandle((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE),_O_TEXT); hf = _fdopen( hCrt, "w" ); *stdout = *hf; // stop the buffer on stdout // int i = setvbuf( stdout, NULL, _IONBF, 0 ); // filebuf ff(hCrt); // cout = &ff; cout<<"This Debug Window is defined in WinMain.cpp and will disappear in release mode"<<endl; #endif // DISPLAYCONSOLE // By Matra // create log file for all OCC messages // Message::DefaultMessenger()->AddPrinter (new Message_PrinterOStream ("OCCSampleRun.log", Standard_False)); ASSERT(hPrevInstance == NULL); int nReturnCode = -1; CWinApp* pApp = AfxGetApp(); // new in 2.0 CAS.CADE uses the standard C++ exception mechanism /*#ifdef _DEBUG // By Matra // _Function declaratiob here because you can jump to InitFailure Standard_ErrorHandler _Function; #endif // _DEBUG // By Matra */ // AFX internal initialization if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; // App global initializations (rare) ASSERT_VALID(pApp); if (!pApp->InitApplication()) goto InitFailure; ASSERT_VALID(pApp); // Perform specific initializations if (!pApp->InitInstance()) { if (pApp->m_pMainWnd != NULL) { TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); pApp->m_pMainWnd->DestroyWindow(); } nReturnCode = pApp->ExitInstance(); goto InitFailure; } ASSERT_VALID(pApp); #ifdef _DEBUG // By Matra Application: // new in 2.0 CAS.CADE uses the standard C++ exception mechanism // if(DoesNotAbort(_Function)) try { nReturnCode = pApp->Run(); } // if(_Function.Catches(STANDARD_TYPE(Standard_Failure))) catch(Standard_Failure) { Standard_SStream ostr; ostr<<Standard_Failure::Caught()<<"\n\0"; CString aMsg = ostr.str().c_str(); MessageBoxW (NULL, aMsg, L"CasCade Error", MB_ICONERROR); goto Application; // restart application loop } #else // _DEBUG // By Matra nReturnCode = pApp->Run(); #endif // _DEBUG // By Matra ASSERT_VALID(pApp); InitFailure: #ifdef _DEBUG // Check for missing AfxLockTempMap calls if (AfxGetModuleThreadState()->m_nTempMapLock != 0) { TRACE1("Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock); } AfxLockTempMaps(); AfxUnlockTempMaps(); #endif AfxWinTerm(); #ifdef DISPLAYCONSOLE // By Matra // ferme la console pour le cout fclose( stdout ); //hCrt = _fcloseall(); :-) rep = FreeConsole(); #endif // DISPLAYCONSOLE // By Matra return nReturnCode; }