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

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