home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / drawcli / drawcli.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  4.7 KB  |  178 lines

  1. // drawcli.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-1998 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 related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "drawcli.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "drawobj.h"
  18. #include "drawdoc.h"
  19. #include "drawvw.h"
  20. #include "splitfrm.h"
  21.  
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CDrawApp
  29.  
  30. BEGIN_MESSAGE_MAP(CDrawApp, CWinApp)
  31.     //{{AFX_MSG_MAP(CDrawApp)
  32.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  33.         // NOTE - the ClassWizard will add and remove mapping macros here.
  34.         //    DO NOT EDIT what you see in these blocks of generated code!
  35.     //}}AFX_MSG_MAP
  36.     // Standard file based document commands
  37.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  38.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  39.     // Standard print setup command
  40.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CDrawApp construction
  45.  
  46. CDrawApp::CDrawApp()
  47. {
  48.     // TODO: add construction code here,
  49.     // Place all significant initialization in InitInstance
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // The one and only CDrawApp object
  54.  
  55. CDrawApp theApp;
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CDrawApp initialization
  59.  
  60. BOOL CDrawApp::InitInstance()
  61. {
  62.         SetRegistryKey(_T("YourCompany"));
  63.     // Initialize OLE libraries
  64.     if (!AfxOleInit())
  65.     {
  66.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  67.         return FALSE;
  68.     }
  69.  
  70.     // Standard initialization
  71.     // If you are not using these features and wish to reduce the size
  72.     //  of your final executable, you should remove from the following
  73.     //  the specific initialization routines you do not need.
  74.  
  75. #ifdef _AFXDLL
  76.     Enable3dControls();         // Call this when using MFC in a shared DLL
  77. #else
  78.     Enable3dControlsStatic();   // Call this when linking to MFC statically
  79. #endif
  80.  
  81.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  82.  
  83.     // Register the application's document templates.  Document templates
  84.     //  serve as the connection between documents, frame windows and views.
  85.  
  86.     CMultiDocTemplate* pDocTemplate;
  87.     pDocTemplate = new CMultiDocTemplate(
  88.         IDR_DRAWCLTYPE,
  89.         RUNTIME_CLASS(CDrawDoc),
  90.         RUNTIME_CLASS(CSplitFrame),
  91.         RUNTIME_CLASS(CDrawView));
  92.     pDocTemplate->SetContainerInfo(IDR_DRAWCLTYPE_CNTR_IP);
  93.     AddDocTemplate(pDocTemplate);
  94.  
  95.     // create main MDI Frame window
  96.     CMainFrame* pMainFrame = new CMainFrame;
  97.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  98.         return FALSE;
  99.     m_pMainWnd = pMainFrame;
  100.  
  101.     // Enable DDE Execute open
  102.     EnableShellOpen();
  103.     RegisterShellFileTypes(TRUE);
  104.  
  105.     // Parse command line for standard shell commands, DDE, file open
  106.     CCommandLineInfo cmdInfo;
  107.     ParseCommandLine(cmdInfo);
  108.  
  109.     // Dispatch commands specified on the command line
  110.     if (!ProcessShellCommand(cmdInfo))
  111.         return FALSE;
  112.  
  113.     // Enable drag/drop open
  114.     m_pMainWnd->DragAcceptFiles();
  115.  
  116.     // The main window has been initialized, so show and update it.
  117.     pMainFrame->ShowWindow(m_nCmdShow);
  118.     pMainFrame->UpdateWindow();
  119.  
  120.     return TRUE;
  121. }
  122.  
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CAboutDlg dialog used for App About
  125.  
  126. class CAboutDlg : public CDialog
  127. {
  128. public:
  129.     CAboutDlg();
  130.  
  131. // Dialog Data
  132.     //{{AFX_DATA(CAboutDlg)
  133.     enum { IDD = IDD_ABOUTBOX };
  134.     //}}AFX_DATA
  135.  
  136.     // ClassWizard generated virtual function overrides
  137.     //{{AFX_VIRTUAL(CAboutDlg)
  138.     protected:
  139.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  140.     //}}AFX_VIRTUAL
  141.  
  142. // Implementation
  143. protected:
  144.     //{{AFX_MSG(CAboutDlg)
  145.         // No message handlers
  146.     //}}AFX_MSG
  147.     DECLARE_MESSAGE_MAP()
  148. };
  149.  
  150. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  151. {
  152.     //{{AFX_DATA_INIT(CAboutDlg)
  153.     //}}AFX_DATA_INIT
  154. }
  155.  
  156. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  157. {
  158.     CDialog::DoDataExchange(pDX);
  159.     //{{AFX_DATA_MAP(CAboutDlg)
  160.     //}}AFX_DATA_MAP
  161. }
  162.  
  163. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  164.     //{{AFX_MSG_MAP(CAboutDlg)
  165.         // No message handlers
  166.     //}}AFX_MSG_MAP
  167. END_MESSAGE_MAP()
  168.  
  169. // App command to run the dialog
  170. void CDrawApp::OnAppAbout()
  171. {
  172.     CAboutDlg aboutDlg;
  173.     aboutDlg.DoModal();
  174. }
  175.  
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CDrawApp commands
  178.