home *** CD-ROM | disk | FTP | other *** search
/ The Houseplan Collection / HRCD2005.ISO / data1.cab / Zusatz / 3DS / DATA2.Z / DialogExplorer.cpp < prev    next >
C/C++ Source or Header  |  1998-11-23  |  2KB  |  93 lines

  1. // DialogExplorer.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DialogExplorer.h"
  6. #include "ArConEventSink.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CDialogExplorer
  16.  
  17. BEGIN_MESSAGE_MAP(CDialogExplorer, CWinApp)
  18.     //{{AFX_MSG_MAP(CDialogExplorer)
  19.     //}}AFX_MSG
  20.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  21. END_MESSAGE_MAP()
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CDialogExplorer construction
  25.  
  26. CDialogExplorer::CDialogExplorer()
  27. {
  28. }
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // The one and only CDialogExplorer object
  32.  
  33. CDialogExplorer theApp;
  34.  
  35. IArCon * theExe = NULL;
  36. ArConEventSink * theEventSink = NULL;
  37.  
  38. // Diese Funktion kann mehrfach aufgerufen werden, je nach Reihenfolge
  39. // des Beendens (erst ArCon, dann das Makro oder andersherum).
  40. void CleanupConnection()
  41. {
  42.   if (theEventSink) {
  43.     theEventSink->Disconnect();
  44.     theEventSink->ExternalRelease();
  45.     theEventSink = NULL;
  46.   }
  47.   if (theExe) {
  48.     theExe->Release();
  49.     theExe = NULL;
  50.   }
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CDialogExplorer initialization
  55.  
  56. BOOL CDialogExplorer::InitInstance()
  57. {
  58.     // Standard initialization
  59.   AfxOleInit();
  60.  
  61. #ifdef _AFXDLL
  62.     Enable3dControls();            // Call this when using MFC in a shared DLL
  63. #else
  64.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  65. #endif
  66.  
  67.   if (FAILED(CoCreateInstance(CLSID_ArCon, NULL, CLSCTX_LOCAL_SERVER, IID_IArCon, (void**)&theExe))) {
  68.     CString msg;
  69.     msg.LoadString(IDS_NO_ARCON);
  70.     AfxMessageBox(msg);
  71.     return FALSE;
  72.   }
  73.  
  74.   theEventSink = new ArConEventSink(theExe);
  75.  
  76.   VARIANT_BOOL res;
  77.   theExe->StartMe(0, NULL, &res);
  78.  
  79.     return TRUE;
  80. }
  81.  
  82. // Main running routine until application exits
  83. int CDialogExplorer::Run()
  84. {
  85.     return CWinThread::Run();
  86. }
  87.  
  88. int CDialogExplorer::ExitInstance() 
  89. {
  90.   CleanupConnection();
  91.     return CWinApp::ExitInstance();
  92. }
  93.