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

  1. // diblook.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 "diblook.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "dibdoc.h"
  18. #include "dibview.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDibLookApp
  27.  
  28. BEGIN_MESSAGE_MAP(CDibLookApp, CWinApp)
  29.     //{{AFX_MSG_MAP(CDibLookApp)
  30.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  31.     //}}AFX_MSG_MAP
  32.     // Standard file based document commands
  33.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  34.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  35.     // Standard print setup command
  36.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CDibLookApp construction
  41. // Place all significant initialization in InitInstance
  42.  
  43. CDibLookApp::CDibLookApp()
  44. {
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // The one and only CDibLookApp object
  49.  
  50. CDibLookApp NEAR theApp;
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CDibLookApp initialization
  54.  
  55. BOOL CDibLookApp::InitInstance()
  56. {
  57.     // Standard initialization
  58.     //  (if you are not using these features and wish to reduce the size
  59.     // of your final executable, you should remove the following initialization
  60.  
  61.     Enable3dControls();     // Use 3d controls in dialogs
  62.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  63.  
  64.     // Register document templates which serve as connection between
  65.     //  documents and views.  Views are contained in the specified view
  66.  
  67.     AddDocTemplate(new CMultiDocTemplate(IDR_DIBTYPE,
  68.             RUNTIME_CLASS(CDibDoc),
  69.             RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
  70.             RUNTIME_CLASS(CDibView)));
  71.  
  72.     // create main MDI Frame window
  73.     CMainFrame* pMainFrame = new CMainFrame;
  74.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  75.         return FALSE;
  76.     pMainFrame->ShowWindow(m_nCmdShow);
  77.     pMainFrame->UpdateWindow();
  78.     m_pMainWnd = pMainFrame;
  79.  
  80.     // enable file manager drag/drop and DDE Execute open
  81.     m_pMainWnd->DragAcceptFiles();
  82.  
  83.     EnableShellOpen();
  84.     RegisterShellFileTypes(TRUE);
  85.  
  86.     // Parse command line for standard shell commands, DDE, file open
  87.     CCommandLineInfo cmdInfo;
  88.     ParseCommandLine(cmdInfo);
  89.  
  90.     // Dispatch commands specified on the command line
  91.     if (!ProcessShellCommand(cmdInfo))
  92.         return FALSE;
  93.  
  94.     return TRUE;
  95. }
  96.  
  97. /////////////////////////////////////////////////////////////////////////////
  98. // CAboutDlg dialog used for App About
  99.  
  100. class CAboutDlg : public CDialog
  101. {
  102. public:
  103.     CAboutDlg() : CDialog(CAboutDlg::IDD)
  104.         {
  105.             //{{AFX_DATA_INIT(CAboutDlg)
  106.             //}}AFX_DATA_INIT
  107.         }
  108.  
  109. // Dialog Data
  110.     //{{AFX_DATA(CAboutDlg)
  111.         enum { IDD = IDD_ABOUTBOX };
  112.     //}}AFX_DATA
  113.  
  114. // Implementation
  115. protected:
  116.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  117.     //{{AFX_MSG(CAboutDlg)
  118.         // No message handlers
  119.     //}}AFX_MSG
  120.     DECLARE_MESSAGE_MAP()
  121. };
  122.  
  123. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  124. {
  125.     CDialog::DoDataExchange(pDX);
  126.     //{{AFX_DATA_MAP(CAboutDlg)
  127.     //}}AFX_DATA_MAP
  128. }
  129.  
  130. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  131.     //{{AFX_MSG_MAP(CAboutDlg)
  132.         // No message handlers
  133.     //}}AFX_MSG_MAP
  134. END_MESSAGE_MAP()
  135.  
  136. // App command to run the dialog
  137. void CDibLookApp::OnAppAbout()
  138. {
  139.     CAboutDlg aboutDlg;
  140.     aboutDlg.DoModal();
  141. }
  142.  
  143. /////////////////////////////////////////////////////////////////////////////
  144. // CDibLookApp commands
  145.