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

  1. // Query.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Query.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "QueryDoc.h"
  9. #include "QueryView.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. // CQueryApp
  19.  
  20. BEGIN_MESSAGE_MAP(CQueryApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CQueryApp)
  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. // CQueryApp construction
  33.  
  34. CQueryApp::CQueryApp()
  35. {
  36.     // TODO: add construction code here,
  37.     // Place all significant initialization in InitInstance
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CQueryApp object
  42.  
  43. CQueryApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CQueryApp initialization
  47.  
  48. BOOL CQueryApp::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.     // Change the registry key under which our settings are stored.
  62.     // You should modify this string to be something appropriate
  63.     // such as the name of your company or organization.
  64.     SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  65.  
  66.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  67.  
  68.     // Register the application's document templates.  Document templates
  69.     //  serve as the connection between documents, frame windows and views.
  70.  
  71.     CSingleDocTemplate* pDocTemplate;
  72.     pDocTemplate = new CSingleDocTemplate(
  73.         IDR_MAINFRAME,
  74.         RUNTIME_CLASS(CQueryDoc),
  75.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  76.         RUNTIME_CLASS(CQueryView));
  77.     AddDocTemplate(pDocTemplate);
  78.  
  79.     // Parse command line for standard shell commands, DDE, file open
  80.     CCommandLineInfo cmdInfo;
  81.     ParseCommandLine(cmdInfo);
  82.  
  83.     // Dispatch commands specified on the command line
  84.     if (!ProcessShellCommand(cmdInfo))
  85.         return FALSE;
  86.  
  87.     // The one and only window has been initialized, so show and update it.
  88.     m_pMainWnd->ShowWindow(SW_SHOW);
  89.     m_pMainWnd->UpdateWindow();
  90.  
  91.     return TRUE;
  92. }
  93.  
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CAboutDlg dialog used for App About
  96.  
  97. class CAboutDlg : public CDialog
  98. {
  99. public:
  100.     CAboutDlg();
  101.  
  102. // Dialog Data
  103.     //{{AFX_DATA(CAboutDlg)
  104.     enum { IDD = IDD_ABOUTBOX };
  105.     //}}AFX_DATA
  106.  
  107.     // ClassWizard generated virtual function overrides
  108.     //{{AFX_VIRTUAL(CAboutDlg)
  109.     protected:
  110.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  111.     //}}AFX_VIRTUAL
  112.  
  113. // Implementation
  114. protected:
  115.     //{{AFX_MSG(CAboutDlg)
  116.         // No message handlers
  117.     //}}AFX_MSG
  118.     DECLARE_MESSAGE_MAP()
  119. };
  120.  
  121. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  122. {
  123.     //{{AFX_DATA_INIT(CAboutDlg)
  124.     //}}AFX_DATA_INIT
  125. }
  126.  
  127. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  128. {
  129.     CDialog::DoDataExchange(pDX);
  130.     //{{AFX_DATA_MAP(CAboutDlg)
  131.     //}}AFX_DATA_MAP
  132. }
  133.  
  134. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  135.     //{{AFX_MSG_MAP(CAboutDlg)
  136.         // No message handlers
  137.     //}}AFX_MSG_MAP
  138. END_MESSAGE_MAP()
  139.  
  140. // App command to run the dialog
  141. void CQueryApp::OnAppAbout()
  142. {
  143.     CAboutDlg aboutDlg;
  144.     aboutDlg.DoModal();
  145. }
  146.  
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CQueryApp commands
  149.