home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / WINMAIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  1.9 KB  |  72 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1997 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_CORE1_SEG
  14. #pragma code_seg(AFX_CORE1_SEG)
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // Standard WinMain implementation
  19. //  Can be replaced as long as 'AfxWinInit' is called first
  20.  
  21. int AFXAPI AfxWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  22.     LPTSTR lpCmdLine, int nCmdShow)
  23. {
  24.     ASSERT(hPrevInstance == NULL);
  25.  
  26.     int nReturnCode = -1;
  27.     CWinApp* pApp = AfxGetApp();
  28.  
  29.     // AFX internal initialization
  30.     if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
  31.         goto InitFailure;
  32.  
  33.     // App global initializations (rare)
  34.     ASSERT_VALID(pApp);
  35.     if (!pApp->InitApplication())
  36.         goto InitFailure;
  37.     ASSERT_VALID(pApp);
  38.  
  39.     // Perform specific initializations
  40.     if (!pApp->InitInstance())
  41.     {
  42.         if (pApp->m_pMainWnd != NULL)
  43.         {
  44.             TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
  45.             pApp->m_pMainWnd->DestroyWindow();
  46.         }
  47.         nReturnCode = pApp->ExitInstance();
  48.         goto InitFailure;
  49.     }
  50.     ASSERT_VALID(pApp);
  51.  
  52.     nReturnCode = pApp->Run();
  53.     ASSERT_VALID(pApp);
  54.  
  55. InitFailure:
  56. #ifdef _DEBUG
  57.     // Check for missing AfxLockTempMap calls
  58.     if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
  59.     {
  60.         TRACE1("Warning: Temp map lock count non-zero (%ld).\n",
  61.             AfxGetModuleThreadState()->m_nTempMapLock);
  62.     }
  63.     AfxLockTempMaps();
  64.     AfxUnlockTempMaps(-1);
  65. #endif
  66.  
  67.     AfxWinTerm();
  68.     return nReturnCode;
  69. }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72.