home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n03 / bocole.exe / MDI.CPP < prev    next >
C/C++ Source or Header  |  1995-03-01  |  3KB  |  122 lines

  1. // mdi.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14.  
  15. #include "stdafx.h"
  16. #include "mdi.h"
  17. #include "ocf4mfc.h"
  18.  
  19. #include "mainfrm.h"
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char BASED_CODE THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26.  
  27. //
  28. // OCF variables
  29. //
  30. TRegLink* RegLinkHead = 0;
  31. TOleInit* OleInit     = 0;
  32.  
  33. //
  34. // OLE Registration information
  35. //
  36. REGISTRATION_FORMAT_BUFFER(100)
  37. BEGIN_REGISTRATION(AppReg)
  38.   REGDATA(clsid,       "{2C27A720-D323-101B-96B9-7A117CB6AF38}")
  39.   REGDATA(progid,      "MFCMDI.ProgID.1")
  40.   REGDATA(description, "MFC Sample using OCF")
  41. END_REGISTRATION
  42.  
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CMdiApp
  46.  
  47. BEGIN_MESSAGE_MAP(CMdiApp, CWinApp)
  48.   //{{AFX_MSG_MAP(CMdiApp)
  49.   ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  50.   //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CMdiApp construction
  55. // Place all significant initialization in InitInstance
  56.  
  57. CMdiApp::CMdiApp()
  58. {
  59.   try {
  60.     OleInit = new TOleInit(::AppReg, 
  61.                           /*Factory Callback*/0, 
  62.                           string(m_lpCmdLine),
  63.                           ::RegLinkHead, 
  64.                           m_hInstance);
  65.   }
  66.   catch (TXBase& xbase) {
  67.     MessageBox(GetFocus(), xbase.why().c_str(), "Exception caught", MB_OK);
  68.   }
  69. }
  70.  
  71. CMdiApp::~CMdiApp()
  72. {
  73.   delete OleInit;
  74. }
  75.  
  76. /////////////////////////////////////////////////////////////////////////////
  77. // The one and only CMdiApp object
  78.  
  79. CMdiApp NEAR theApp;
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CMdiApp initialization
  83.  
  84. BOOL CMdiApp::InitInstance()
  85. {
  86.   SetDialogBkColor();
  87.  
  88.   // create main MDI Frame window
  89.   CMainFrame* pMainFrame = new CMainFrame;
  90.   if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  91.     return FALSE;
  92.   pMainFrame->ShowWindow(m_nCmdShow);
  93.   pMainFrame->UpdateWindow();
  94.   m_pMainWnd = pMainFrame;
  95.  
  96.   // load the two static menus
  97.   return TRUE;
  98. }
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CMdiApp commands
  102.  
  103. void CMdiApp::OnAppAbout()
  104. {
  105.   CDialog(IDD_ABOUTBOX).DoModal();
  106. }
  107.  
  108. /////////////////////////////////////////////////////////////////////////////
  109. // other globals
  110.  
  111. // Color array maps to Color menu
  112. COLORREF NEAR colorArray[] =
  113. {
  114.   RGB (0, 0, 0),
  115.   RGB (255, 0, 0),
  116.   RGB (0, 255, 0),
  117.   RGB (0, 0, 255),
  118.   RGB (255, 255, 255)
  119. };
  120.  
  121. /////////////////////////////////////////////////////////////////////////////
  122.