home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / APPTERM.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  2.7 KB  |  90 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. #include <ddeml.h> // for MSGF_DDEMGR
  13.  
  14. #ifdef AFX_TERM_SEG
  15. #pragma code_seg(AFX_TERM_SEG)
  16. #endif
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // other globals (internal library use)
  25.  
  26. #ifdef _MAC
  27. AEEventHandlerUPP _afxPfnOpenApp;
  28. AEEventHandlerUPP _afxPfnOpenDoc;
  29. AEEventHandlerUPP _afxPfnPrintDoc;
  30. AEEventHandlerUPP _afxPfnQuit;
  31. #endif
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Standard cleanup called by WinMain and AfxAbort
  35.  
  36. void AFXAPI AfxWinTerm(void)
  37. {
  38. #ifdef _MAC
  39.     AERemoveEventHandler(kCoreEventClass, kAEOpenApplication, _afxPfnOpenApp, false);
  40.     AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, _afxPfnOpenDoc, false);
  41.     AERemoveEventHandler(kCoreEventClass, kAEPrintDocuments, _afxPfnPrintDoc, false);
  42.     AERemoveEventHandler(kCoreEventClass, kAEQuitApplication, _afxPfnQuit, false);
  43. #endif
  44.  
  45.     // unregister Window classes
  46.     AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
  47.     AfxLockGlobals(CRIT_REGCLASSLIST);
  48.     LPTSTR lpsz = pModuleState->m_szUnregisterList;
  49.     while (*lpsz != 0)
  50.     {
  51.         LPTSTR lpszEnd = _tcschr(lpsz, '\n');
  52.         ASSERT(lpszEnd != NULL);
  53.         *lpszEnd = 0;
  54.         UnregisterClass(lpsz, AfxGetInstanceHandle());
  55.         lpsz = lpszEnd + 1;
  56.     }
  57.     pModuleState->m_szUnregisterList[0] = 0;
  58.     AfxUnlockGlobals(CRIT_REGCLASSLIST);
  59.  
  60.     // cleanup OLE if required
  61.     CWinThread* pThread = AfxGetApp();
  62.     if (pThread != NULL && pThread->m_lpfnOleTermOrFreeLib != NULL)
  63.         (*pThread->m_lpfnOleTermOrFreeLib)(TRUE, FALSE);
  64.  
  65.     // cleanup thread local tooltip window
  66.     _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
  67.     if (pThreadState->m_pToolTip != NULL)
  68.     {
  69.         if (pThreadState->m_pToolTip->DestroyToolTipCtrl())
  70.             pThreadState->m_pToolTip = NULL;
  71.     }
  72.  
  73.     if (!afxContextIsDLL)
  74.     {
  75.         // unhook windows hooks
  76.         if (pThreadState->m_hHookOldMsgFilter != NULL)
  77.         {
  78.             ::UnhookWindowsHookEx(pThreadState->m_hHookOldMsgFilter);
  79.             pThreadState->m_hHookOldMsgFilter = NULL;
  80.         }
  81.         if (pThreadState->m_hHookOldCbtFilter != NULL)
  82.         {
  83.             ::UnhookWindowsHookEx(pThreadState->m_hHookOldCbtFilter);
  84.             pThreadState->m_hHookOldCbtFilter = NULL;
  85.         }
  86.     }
  87. }
  88.  
  89. /////////////////////////////////////////////////////////////////////////////
  90.