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

  1. // multipad.cpp : Defines the class behaviors for the Multipad 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 "multipad.h"
  15. #include <locale.h>
  16.  
  17. CMultiPadApp NEAR theApp;
  18.  
  19. BEGIN_MESSAGE_MAP(CMultiPadApp, CWinApp)
  20.     //{{AFX_MSG_MAP(CMultiPadApp)
  21.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22.     //}}AFX_MSG_MAP
  23.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)     // file commands...
  24.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  25.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  26. END_MESSAGE_MAP()
  27.  
  28. BOOL CMultiPadApp::InitInstance()
  29. {
  30.     _tsetlocale(LC_ALL, _T(""));
  31.  
  32.     Enable3dControls();
  33.     LoadStdProfileSettings();
  34.  
  35.     AddDocTemplate(new CMultiDocTemplate(IDR_TEXTTYPE,
  36.         RUNTIME_CLASS(CPadDoc), RUNTIME_CLASS(CMDIChildWnd),
  37.         RUNTIME_CLASS(CEditView)));
  38.     m_pMainWnd = new CMainFrame;
  39.     ((CFrameWnd*)m_pMainWnd)->LoadFrame(IDR_MAINFRAME);
  40.     m_pMainWnd->ShowWindow(m_nCmdShow);
  41.  
  42.     // enable file manager drag/drop and DDE Execute open
  43.     m_pMainWnd->DragAcceptFiles();
  44.     EnableShellOpen();
  45.     RegisterShellFileTypes(TRUE);
  46.  
  47.     // Parse command line for standard shell commands, DDE, file open
  48.     CCommandLineInfo cmdInfo;
  49.     ParseCommandLine(cmdInfo);
  50.  
  51.     // Dispatch commands specified on the command line
  52.     if (!ProcessShellCommand(cmdInfo))
  53.         return FALSE;
  54.  
  55.     return TRUE;
  56. }
  57.  
  58. void CMultiPadApp::OnAppAbout()
  59. {
  60.     CDialog(IDD_ABOUTBOX).DoModal();
  61. }
  62.  
  63. IMPLEMENT_DYNCREATE(CMainFrame, CMDIFrameWnd)
  64. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  65.     //{{AFX_MSG_MAP(CMainFrame)
  66.     ON_WM_CREATE()
  67.     //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69.  
  70. static UINT buttons[] =
  71. {
  72.     ID_FILE_NEW, ID_FILE_OPEN, ID_FILE_SAVE, ID_SEPARATOR,
  73.     ID_EDIT_CUT, ID_EDIT_COPY, ID_EDIT_PASTE, ID_SEPARATOR,
  74.     ID_FILE_PRINT, ID_APP_ABOUT
  75. };
  76.  
  77. static UINT indicators[] =
  78. {
  79.     ID_SEPARATOR, ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL
  80. };
  81.  
  82. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  83. {
  84.     ((m_ToolBar.Create(this) &&
  85.         m_ToolBar.LoadBitmap(IDR_MAINFRAME) &&
  86.         m_ToolBar.SetButtons(buttons, sizeof(buttons)/sizeof(UINT)) &&
  87.         m_StatusBar.Create(this) &&
  88.         m_StatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))
  89.       ? 0 : -1);
  90.     return CMDIFrameWnd::OnCreate(lpCreateStruct);
  91. }
  92.  
  93. IMPLEMENT_DYNCREATE(CPadDoc, CDocument)
  94. BEGIN_MESSAGE_MAP(CPadDoc, CDocument)
  95.     //{{AFX_MSG_MAP(CPadDoc)
  96.     //}}AFX_MSG_MAP
  97. END_MESSAGE_MAP()
  98.  
  99. void CPadDoc::Serialize(CArchive& ar)
  100. {
  101.     ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
  102. }
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105.