home *** CD-ROM | disk | FTP | other *** search
/ Mastering Microsoft Visual C++ 4 (2nd Edition) / VisualC4.ISO / formdemo / formdemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  3.8 KB  |  142 lines

  1. // FormDemo.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "FormDemo.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "FormDDoc.h"
  9. #include "FormDeVw.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CFormDemoApp
  19.  
  20. BEGIN_MESSAGE_MAP(CFormDemoApp, CWinApp)
  21.    //{{AFX_MSG_MAP(CFormDemoApp)
  22.    ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23.       // NOTE - the ClassWizard will add and remove mapping macros here.
  24.       //    DO NOT EDIT what you see in these blocks of generated code!
  25.    //}}AFX_MSG_MAP
  26.    // Standard file based document commands
  27.    ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  28.    ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  29. END_MESSAGE_MAP()
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CFormDemoApp construction
  33.  
  34. CFormDemoApp::CFormDemoApp()
  35. {
  36.    // TODO: add construction code here,
  37.    // Place all significant initialization in InitInstance
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CFormDemoApp object
  42.  
  43. CFormDemoApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CFormDemoApp initialization
  47.  
  48. BOOL CFormDemoApp::InitInstance()
  49. {
  50.    // Standard initialization
  51.    // If you are not using these features and wish to reduce the size
  52.    //  of your final executable, you should remove from the following
  53.    //  the specific initialization routines you do not need.
  54.  
  55. #ifdef _AFXDLL
  56.    Enable3dControls();        // Call this when using MFC in a shared DLL
  57. #else
  58.    Enable3dControlsStatic();  // Call this when linking to MFC statically
  59. #endif
  60.  
  61.    LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  62.  
  63.    // Register the application's document templates.  Document templates
  64.    //  serve as the connection between documents, frame windows and views.
  65.  
  66.    CSingleDocTemplate* pDocTemplate;
  67.    pDocTemplate = new CSingleDocTemplate(
  68.       IDR_MAINFRAME,
  69.       RUNTIME_CLASS(CFormDemoDoc),
  70.       RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  71.       RUNTIME_CLASS(CFormDemoView));
  72.    AddDocTemplate(pDocTemplate);
  73.  
  74.    // Parse command line for standard shell commands, DDE, file open
  75.    CCommandLineInfo cmdInfo;
  76.    ParseCommandLine(cmdInfo);
  77.  
  78.    // Dispatch commands specified on the command line
  79.    if (!ProcessShellCommand(cmdInfo))
  80.       return FALSE;
  81.  
  82.    m_pMainWnd->SetWindowText ("Form-View Demo");
  83.  
  84.    return TRUE;
  85. }
  86.  
  87. /////////////////////////////////////////////////////////////////////////////
  88. // CAboutDlg dialog used for App About
  89.  
  90. class CAboutDlg : public CDialog
  91. {
  92. public:
  93.    CAboutDlg();
  94.  
  95. // Dialog Data
  96.    //{{AFX_DATA(CAboutDlg)
  97.    enum { IDD = IDD_ABOUTBOX };
  98.    //}}AFX_DATA
  99.  
  100.    // ClassWizard generated virtual function overrides
  101.    //{{AFX_VIRTUAL(CAboutDlg)
  102.    protected:
  103.    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  104.    //}}AFX_VIRTUAL
  105.  
  106. // Implementation
  107. protected:
  108.    //{{AFX_MSG(CAboutDlg)
  109.       // No message handlers
  110.    //}}AFX_MSG
  111.    DECLARE_MESSAGE_MAP()
  112. };
  113.  
  114. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  115. {
  116.    //{{AFX_DATA_INIT(CAboutDlg)
  117.    //}}AFX_DATA_INIT
  118. }
  119.  
  120. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  121. {
  122.    CDialog::DoDataExchange(pDX);
  123.    //{{AFX_DATA_MAP(CAboutDlg)
  124.    //}}AFX_DATA_MAP
  125. }
  126.  
  127. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  128.    //{{AFX_MSG_MAP(CAboutDlg)
  129.       // No message handlers
  130.    //}}AFX_MSG_MAP
  131. END_MESSAGE_MAP()
  132.  
  133. // App command to run the dialog
  134. void CFormDemoApp::OnAppAbout()
  135. {
  136.    CAboutDlg aboutDlg;
  137.    aboutDlg.DoModal();
  138. }
  139.  
  140. /////////////////////////////////////////////////////////////////////////////
  141. // CFormDemoApp commands
  142.