1 // vtkMDI.cpp : Defines the class behaviors for the application.
2 //
3 
4 #include "stdafx.h"
5 #include "vtkMDI.h"
6 #include "MainFrm.h"
7 
8 #include "ChildFrm.h"
9 #include "vtkMDIDoc.h"
10 #include "vtkMDIView.h"
11 
12 #ifdef _DEBUG
13 #define new DEBUG_NEW
14 #endif
15 
16 
17 // CvtkMDIApp
18 
BEGIN_MESSAGE_MAP(CvtkMDIApp,CWinApp)19 BEGIN_MESSAGE_MAP(CvtkMDIApp, CWinApp)
20   ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
21   // Standard file based document commands
22   ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
23   ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
24   // Standard print setup command
25   ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
26 END_MESSAGE_MAP()
27 
28 
29 // CvtkMDIApp construction
30 
31 CvtkMDIApp::CvtkMDIApp()
32 {
33   // TODO: add construction code here,
34   // Place all significant initialization in InitInstance
35 }
36 
37 
38 // The one and only CvtkMDIApp object
39 
40 CvtkMDIApp theApp;
41 
42 // CvtkMDIApp initialization
43 
InitInstance()44 BOOL CvtkMDIApp::InitInstance()
45 {
46   // InitCommonControls() is required on Windows XP if an application
47   // manifest specifies use of ComCtl32.dll version 6 or later to enable
48   // visual styles.  Otherwise, any window creation will fail.
49   InitCommonControls();
50 
51   CWinApp::InitInstance();
52 
53   // Standard initialization
54   // If you are not using these features and wish to reduce the size
55   // of your final executable, you should remove from the following
56   // the specific initialization routines you do not need
57   // Change the registry key under which our settings are stored
58   // TODO: You should modify this string to be something appropriate
59   // such as the name of your company or organization
60   SetRegistryKey(_T("Local AppWizard-Generated Applications"));
61   LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
62   // Register the application's document templates.  Document templates
63   //  serve as the connection between documents, frame windows and views
64   CMultiDocTemplate* pDocTemplate;
65   pDocTemplate = new CMultiDocTemplate(IDR_vtkMDITYPE,
66     RUNTIME_CLASS(CvtkMDIDoc),
67     RUNTIME_CLASS(CChildFrame), // custom MDI child frame
68     RUNTIME_CLASS(CvtkMDIView));
69   if (!pDocTemplate)
70     return FALSE;
71   AddDocTemplate(pDocTemplate);
72   // create main MDI Frame window
73   CMainFrame* pMainFrame = new CMainFrame;
74   if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
75     return FALSE;
76   m_pMainWnd = pMainFrame;
77   // call DragAcceptFiles only if there's a suffix
78   //  In an MDI app, this should occur immediately after setting m_pMainWnd
79   // Parse command line for standard shell commands, DDE, file open
80   CCommandLineInfo cmdInfo;
81   ParseCommandLine(cmdInfo);
82   // Dispatch commands specified on the command line.  Will return FALSE if
83   // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
84   if (!ProcessShellCommand(cmdInfo))
85     return FALSE;
86   // The main window has been initialized, so show and update it
87   pMainFrame->ShowWindow(m_nCmdShow);
88   pMainFrame->UpdateWindow();
89   return TRUE;
90 }
91 
92 
93 
94 // CAboutDlg dialog used for App About
95 
96 class CAboutDlg : public CDialog
97 {
98 public:
99   CAboutDlg();
100 
101 // Dialog Data
102   enum { IDD = IDD_ABOUTBOX };
103 
104 protected:
105   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
106 
107 // Implementation
108 protected:
109   DECLARE_MESSAGE_MAP()
110 };
111 
CAboutDlg()112 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
113 {
114 }
115 
DoDataExchange(CDataExchange * pDX)116 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
117 {
118   CDialog::DoDataExchange(pDX);
119 }
120 
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)121 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
122 END_MESSAGE_MAP()
123 
124 // App command to run the dialog
125 void CvtkMDIApp::OnAppAbout()
126 {
127   CAboutDlg aboutDlg;
128   aboutDlg.DoModal();
129 }
130 
131 
132 // CvtkMDIApp message handlers
133 
134