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

  1. // MFCBind.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 "MFCBind.h"
  15.  
  16. #include "MainFrm.h"
  17. #include "BindDoc.h"
  18. #include "BindView.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMFCBindApp
  28.  
  29. BEGIN_MESSAGE_MAP(CMFCBindApp, CWinApp)
  30.     //{{AFX_MSG_MAP(CMFCBindApp)
  31.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  32.         // NOTE - the ClassWizard will add and remove mapping macros here.
  33.         //    DO NOT EDIT what you see in these blocks of generated code!
  34.     //}}AFX_MSG_MAP
  35.     // Standard file based document commands
  36.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  37.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  38.     // Standard print setup command
  39.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CMFCBindApp construction
  44.  
  45. CMFCBindApp::CMFCBindApp()
  46. {
  47.     // TODO: add construction code here,
  48.     // Place all significant initialization in InitInstance
  49. }
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // The one and only CMFCBindApp object
  53.  
  54. CMFCBindApp theApp;
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CMFCBindApp initialization
  58.  
  59. BOOL CMFCBindApp::InitInstance()
  60. {
  61.     // Initialize OLE libraries
  62.     if (!AfxOleInit())
  63.     {
  64.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  65.         return FALSE;
  66.     }
  67.  
  68.     // Standard initialization
  69.     // If you are not using these features and wish to reduce the size
  70.     //  of your final executable, you should remove from the following
  71.     //  the specific initialization routines you do not need.
  72.  
  73. #ifdef _AFXDLL
  74.     Enable3dControls();         // Call this when using MFC in a shared DLL
  75. #else
  76.     Enable3dControlsStatic();   // Call this when linking to MFC statically
  77. #endif
  78.  
  79.     // Change the registry key under which our settings are stored.
  80.     // You should modify this string to be something appropriate
  81.     // such as the name of your company or organization.
  82.     SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  83.  
  84.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  85.  
  86.     // Register the application's document templates.  Document templates
  87.     //  serve as the connection between documents, frame windows and views.
  88.  
  89.     CSingleDocTemplate* pDocTemplate;
  90.     pDocTemplate = new CSingleDocTemplate(
  91.         IDR_MAINFRAME,
  92.         RUNTIME_CLASS(CMFCBindDoc),
  93.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  94.         RUNTIME_CLASS(CMFCBindView));
  95.     pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
  96.     AddDocTemplate(pDocTemplate);
  97.  
  98.     // Parse command line for standard shell commands, DDE, file open
  99.     CCommandLineInfo cmdInfo;
  100.     ParseCommandLine(cmdInfo);
  101.  
  102.     // Dispatch commands specified on the command line
  103.     if (!ProcessShellCommand(cmdInfo))
  104.         return FALSE;
  105.  
  106.     // The one and only window has been initialized, so show and update it.
  107.     m_pMainWnd->ShowWindow(SW_SHOW);
  108.     m_pMainWnd->UpdateWindow();
  109.  
  110.     return TRUE;
  111. }
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CAboutDlg dialog used for App About
  115.  
  116. class CAboutDlg : public CDialog
  117. {
  118. public:
  119.     CAboutDlg();
  120.  
  121. // Dialog Data
  122.     //{{AFX_DATA(CAboutDlg)
  123.     enum { IDD = IDD_ABOUTBOX };
  124.     //}}AFX_DATA
  125.  
  126.     // ClassWizard generated virtual function overrides
  127.     //{{AFX_VIRTUAL(CAboutDlg)
  128.     protected:
  129.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  130.     //}}AFX_VIRTUAL
  131.  
  132. // Implementation
  133. protected:
  134.     //{{AFX_MSG(CAboutDlg)
  135.         // No message handlers
  136.     //}}AFX_MSG
  137.     DECLARE_MESSAGE_MAP()
  138. };
  139.  
  140. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  141. {
  142.     //{{AFX_DATA_INIT(CAboutDlg)
  143.     //}}AFX_DATA_INIT
  144. }
  145.  
  146. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  147. {
  148.     CDialog::DoDataExchange(pDX);
  149.     //{{AFX_DATA_MAP(CAboutDlg)
  150.     //}}AFX_DATA_MAP
  151. }
  152.  
  153. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  154.     //{{AFX_MSG_MAP(CAboutDlg)
  155.         // No message handlers
  156.     //}}AFX_MSG_MAP
  157. END_MESSAGE_MAP()
  158.  
  159. // App command to run the dialog
  160. void CMFCBindApp::OnAppAbout()
  161. {
  162.     CAboutDlg aboutDlg;
  163.     aboutDlg.DoModal();
  164. }
  165.  
  166. /////////////////////////////////////////////////////////////////////////////
  167. // CMFCBindApp commands
  168.