home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / advanced / chatter / chatter.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.6 KB  |  139 lines

  1. // chatter.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "chatter.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "chatdoc.h"
  18. #include "chatvw.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CChatterApp
  27.  
  28. BEGIN_MESSAGE_MAP(CChatterApp, CWinApp)
  29.     //{{AFX_MSG_MAP(CChatterApp)
  30.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  31.         // NOTE - the ClassWizard will add and remove mapping macros here.
  32.         //    DO NOT EDIT what you see in these blocks of generated code!
  33.     //}}AFX_MSG_MAP
  34.     // Standard file based document commands
  35.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CChatterApp construction
  41.  
  42. CChatterApp::CChatterApp()
  43. {
  44. }
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // The one and only CChatterApp object
  48.  
  49. CChatterApp theApp;
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CChatterApp initialization
  53.  
  54. BOOL CChatterApp::InitInstance()
  55. {
  56.     if (!AfxSocketInit())
  57.     {
  58.         AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
  59.         return FALSE;
  60.     }
  61.  
  62.     // Standard initialization
  63.     // If you are not using these features and wish to reduce the size
  64.     //  of your final executable, you should remove from the following
  65.     //  the specific initialization routines you do not need.
  66.  
  67. #ifdef _WIN32
  68.     Enable3dControls();
  69. #endif
  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(CChatDoc),
  80.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  81.         RUNTIME_CLASS(CChatView));
  82.     AddDocTemplate(pDocTemplate);
  83.  
  84.     OnFileNew();
  85.  
  86.     return !(m_pMainWnd == NULL);
  87. }
  88.  
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CAboutDlg dialog used for App About
  91.  
  92. class CAboutDlg : public CDialog
  93. {
  94. public:
  95.     CAboutDlg();
  96.  
  97. // Dialog Data
  98.     //{{AFX_DATA(CAboutDlg)
  99.     enum { IDD = IDD_ABOUTBOX };
  100.     //}}AFX_DATA
  101.  
  102. // Implementation
  103. protected:
  104.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  105.     //{{AFX_MSG(CAboutDlg)
  106.         // No message handlers
  107.     //}}AFX_MSG
  108.     DECLARE_MESSAGE_MAP()
  109. };
  110.  
  111. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  112. {
  113.     //{{AFX_DATA_INIT(CAboutDlg)
  114.     //}}AFX_DATA_INIT
  115. }
  116.  
  117. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  118. {
  119.     CDialog::DoDataExchange(pDX);
  120.     //{{AFX_DATA_MAP(CAboutDlg)
  121.     //}}AFX_DATA_MAP
  122. }
  123.  
  124. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  125.     //{{AFX_MSG_MAP(CAboutDlg)
  126.         // No message handlers
  127.     //}}AFX_MSG_MAP
  128. END_MESSAGE_MAP()
  129.  
  130. // App command to run the dialog
  131. void CChatterApp::OnAppAbout()
  132. {
  133.     CAboutDlg aboutDlg;
  134.     aboutDlg.DoModal();
  135. }
  136.  
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CChatterApp commands
  139.