home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / scroll / scroll.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.7 KB  |  142 lines

  1. // Scroll.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Scroll.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "ScrolDoc.h"
  9. #include "ScroView.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. // CScrollApp
  19.  
  20. BEGIN_MESSAGE_MAP(CScrollApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CScrollApp)
  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.     // Standard print setup command
  30.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CScrollApp construction
  35.  
  36. CScrollApp::CScrollApp()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // The one and only CScrollApp object
  44.  
  45. CScrollApp theApp;
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CScrollApp initialization
  49.  
  50. BOOL CScrollApp::InitInstance()
  51. {
  52.     // Standard initialization
  53.     // If you are not using these features and wish to reduce the size
  54.     //  of your final executable, you should remove from the following
  55.     //  the specific initialization routines you do not need.
  56.  
  57. #ifdef _AFXDLL
  58.     Enable3dControls();            // Call this when using MFC in a shared DLL
  59. #else
  60.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  61. #endif
  62.  
  63.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  64.  
  65.     // Register the application's document templates.  Document templates
  66.     //  serve as the connection between documents, frame windows and views.
  67.  
  68.     CSingleDocTemplate* pDocTemplate;
  69.     pDocTemplate = new CSingleDocTemplate(
  70.         IDR_MAINFRAME,
  71.         RUNTIME_CLASS(CScrollDoc),
  72.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  73.         RUNTIME_CLASS(CMyScrollView));
  74.     AddDocTemplate(pDocTemplate);
  75.  
  76.         // Parse command line for standard shell commands, DDE, file open
  77.     CCommandLineInfo cmdInfo;
  78.     ParseCommandLine(cmdInfo);
  79.  
  80.     // Dispatch commands specified on the command line
  81.     if (!ProcessShellCommand(cmdInfo))
  82.         return FALSE;
  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 CScrollApp::OnAppAbout()
  135. {
  136.     CAboutDlg aboutDlg;
  137.     aboutDlg.DoModal();
  138. }
  139.  
  140. /////////////////////////////////////////////////////////////////////////////
  141. // CScrollApp commands
  142.