本文整理汇总了C++中CWinApp::ExitInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::ExitInstance方法的具体用法?C++ CWinApp::ExitInstance怎么用?C++ CWinApp::ExitInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::ExitInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessGUIMessages
virtual void ProcessGUIMessages()
{
// Adapted from MFC's CWinThread::Run() (thrdcore.cpp).
_AFX_THREAD_STATE* pState = AfxGetThreadState();
CWinApp* pApp = AfxGetApp();
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(&pState->m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// call OnIdle while in bIdle state
if (!pApp->OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
}
// phase2: pump messages while available
while (::PeekMessage(&pState->m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// pump message, but quit on WM_QUIT
if (!pApp->PumpMessage())
{
Terminate();
pApp->ExitInstance();
}
}
::Sleep(0);
}
示例2: WinMain
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
app.InitInstance( hInstance, szCmdLine, iCmdShow );
app.Run();
return app.ExitInstance();
}//WinMain()
示例3: OnEndSession
void CFrameWnd::OnEndSession( BOOL bEnding )
/******************************************/
{
if( bEnding ) {
CWinApp *pApp = AfxGetApp();
if( pApp != NULL && pApp->m_pMainWnd == this ) {
pApp->CloseAllDocuments( TRUE );
pApp->ExitInstance();
}
}
}
示例4: WinMain
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
AfxWinInit(hInst, hPrevInst, lpCmdLine, nCmdShow);
CWinApp* pApp = AfxGetApp();
if ( ! pApp->InitInstance())
{
return 1;
}
int result = pApp->Run();
pApp->ExitInstance();
return result;
}
示例5: ASSERT
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;
}
示例6: main
int main() {
CWinApp* pApp = AfxGetApp();
if (pApp->InitInstance()) pApp->Run();
pApp->ExitInstance();
}
示例7: AfxWinMain
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;
}
示例8: if
extern "C" BOOL WINAPI
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
CWinApp* pApp = AfxGetApp();
if (dwReason == DLL_PROCESS_ATTACH)
{
// initialize MFC exception handling
#ifndef _AFX_OLD_EXCEPTIONS
set_terminate(&AfxStandardTerminate);
#endif
_set_new_handler(&AfxNewHandler);
// initialize DLL's instance(/module) not the app's
if (!AfxWinInit(hInstance, NULL, &afxChNil, 0))
{
AfxWinTerm();
return FALSE; // Init Failed
}
// initialize the single instance DLL
if (pApp != NULL && !pApp->InitInstance())
{
pApp->ExitInstance();
AfxWinTerm();
return FALSE; // Init Failed
}
}
else if (dwReason == DLL_PROCESS_DETACH)
{
if (pApp != NULL)
pApp->ExitInstance();
#ifdef _DEBUG
// check for missing AfxLockTempMap calls
if (AfxGetThreadState()->m_nTempMapLock != 0)
TRACE1("Warning: Temp map lock count non-zero (%ld).\n",
AfxGetThreadState()->m_nTempMapLock);
#endif
// terminate the library before destructors are called
AfxWinTerm();
// free safety pool buffer
AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
if (pThreadState->m_pSafetyPoolBuffer != NULL)
{
free(pThreadState->m_pSafetyPoolBuffer);
pThreadState->m_pSafetyPoolBuffer = NULL;
}
#ifdef _DEBUG
// trace any memory leaks that may have occurred
AfxDumpMemoryLeaks();
#endif
// clean up map objects before it is too late
delete pThreadState->m_pmapHWND;
pThreadState->m_pmapHWND = NULL;
delete pThreadState->m_pmapHMENU;
pThreadState->m_pmapHMENU = NULL;
delete pThreadState->m_pmapHDC;
pThreadState->m_pmapHDC = NULL;
delete pThreadState->m_pmapHGDIOBJ;
pThreadState->m_pmapHGDIOBJ = NULL;
delete pThreadState->m_pmapHIMAGELIST;
pThreadState->m_pmapHIMAGELIST = NULL;
pThreadState->m_mapSocketHandle.CMapPtrToPtr::~CMapPtrToPtr();
pThreadState->m_mapDeadSockets.CMapPtrToPtr::~CMapPtrToPtr();
pThreadState->m_listSocketNotifications.CPtrList::~CPtrList();
}
return TRUE; // ok
}
示例9: AfxWinMain
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();
//.........这里部分代码省略.........