home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c11 / lab04 / ex02 / baseline / gpsrc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.7 KB  |  146 lines

  1. // gpsrc.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "gpsrc.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "gpsrcDoc.h"
  9. #include "gpsrcView.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. // CGpsrcApp
  19.  
  20. BEGIN_MESSAGE_MAP(CGpsrcApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CGpsrcApp)
  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. // CGpsrcApp construction
  33.  
  34. CGpsrcApp::CGpsrcApp()
  35. {
  36.     // TODO: add construction code here,
  37.     // Place all significant initialization in InitInstance
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CGpsrcApp object
  42.  
  43. CGpsrcApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CGpsrcApp initialization
  47.  
  48. BOOL CGpsrcApp::InitInstance()
  49. {
  50.     if (!AfxSocketInit())
  51.     {
  52.         AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  53.         return FALSE;
  54.     }
  55.  
  56.     // Standard initialization
  57.     // If you are not using these features and wish to reduce the size
  58.     //  of your final executable, you should remove from the following
  59.     //  the specific initialization routines you do not need.
  60.  
  61. #ifdef _AFXDLL
  62.     Enable3dControls();            // Call this when using MFC in a shared DLL
  63. #else
  64.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  65. #endif
  66.  
  67.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  68.  
  69.     // Register the application's document templates.  Document templates
  70.     //  serve as the connection between documents, frame windows and views.
  71.  
  72.     CSingleDocTemplate* pDocTemplate;
  73.     pDocTemplate = new CSingleDocTemplate(
  74.         IDR_MAINFRAME,
  75.         RUNTIME_CLASS(CGpsrcDoc),
  76.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  77.         RUNTIME_CLASS(CGpsrcView));
  78.     AddDocTemplate(pDocTemplate);
  79.  
  80.     // Parse command line for standard shell commands, DDE, file open
  81.     CCommandLineInfo cmdInfo;
  82.     ParseCommandLine(cmdInfo);
  83.  
  84.     // Dispatch commands specified on the command line
  85.     if (!ProcessShellCommand(cmdInfo))
  86.         return FALSE;
  87.  
  88.     return TRUE;
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CAboutDlg dialog used for App About
  93.  
  94. class CAboutDlg : public CDialog
  95. {
  96. public:
  97.     CAboutDlg();
  98.  
  99. // Dialog Data
  100.     //{{AFX_DATA(CAboutDlg)
  101.     enum { IDD = IDD_ABOUTBOX };
  102.     //}}AFX_DATA
  103.  
  104.     // ClassWizard generated virtual function overrides
  105.     //{{AFX_VIRTUAL(CAboutDlg)
  106.     protected:
  107.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  108.     //}}AFX_VIRTUAL
  109.  
  110. // Implementation
  111. protected:
  112.     //{{AFX_MSG(CAboutDlg)
  113.         // No message handlers
  114.     //}}AFX_MSG
  115.     DECLARE_MESSAGE_MAP()
  116. };
  117.  
  118. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  119. {
  120.     //{{AFX_DATA_INIT(CAboutDlg)
  121.     //}}AFX_DATA_INIT
  122. }
  123.  
  124. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  125. {
  126.     CDialog::DoDataExchange(pDX);
  127.     //{{AFX_DATA_MAP(CAboutDlg)
  128.     //}}AFX_DATA_MAP
  129. }
  130.  
  131. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  132.     //{{AFX_MSG_MAP(CAboutDlg)
  133.         // No message handlers
  134.     //}}AFX_MSG_MAP
  135. END_MESSAGE_MAP()
  136.  
  137. // App command to run the dialog
  138. void CGpsrcApp::OnAppAbout()
  139. {
  140.     CAboutDlg aboutDlg;
  141.     aboutDlg.DoModal();
  142. }
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CGpsrcApp commands
  146.