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

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