1 // GeometryApp.cpp : Defines the class behaviors for the application.
6 #include "GeometryApp.h"
9 #include "GeometryDoc.h"
10 #include "GeometryView.h"
11 #include "GeometryView2d.h"
12 #include "ChildFrm2D.h"
13 #include "GeometryView2d.h"
15 /////////////////////////////////////////////////////////////////////////////
16 // CGeometryApp construction
18 CGeometryApp::CGeometryApp()
20 SampleName = "Geometry"; //for about dialog
24 CGeometryApp::~CGeometryApp()
26 delete pDocTemplateForView2d;
28 /////////////////////////////////////////////////////////////////////////////
29 // The one and only CGeometryApp object
33 /////////////////////////////////////////////////////////////////////////////
34 // CGeometryApp initialization
36 BOOL CGeometryApp::InitInstance()
39 AfxEnableControlContainer();
41 // Standard initialization
42 // If you are not using these features and wish to reduce the size
43 // of your final executable, you should remove from the following
44 // the specific initialization routines you do not need.
46 // Change the registry key under which our settings are stored.
47 // You should modify this string to be something appropriate
48 // such as the name of your company or organization.
49 SetRegistryKey(_T("Local AppWizard-Generated Applications"));
51 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
53 // Register the application's document templates. Document templates
54 // serve as the connection between documents, frame windows and views.
56 pDocTemplateForView3d = new CMultiDocTemplate(
58 RUNTIME_CLASS(CGeometryDoc),
59 RUNTIME_CLASS(CChildFrame), // custom MDI child frame
60 RUNTIME_CLASS(CGeometryView));
61 AddDocTemplate(pDocTemplateForView3d);
63 pDocTemplateForView2d = new CMultiDocTemplate(
65 RUNTIME_CLASS(CGeometryDoc),
66 RUNTIME_CLASS(CChildFrame2D), // custom MDI child frame
67 RUNTIME_CLASS(CGeometryView2D));
68 //AddDocTemplate(pDocTemplateForView2d);
70 // create main MDI Frame window
71 CMainFrame* pMainFrame = new CMainFrame;
72 if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
74 m_pMainWnd = pMainFrame;
76 // Parse command line for standard shell commands, DDE, file open
77 CCommandLineInfo cmdInfo;
78 ParseCommandLine(cmdInfo);
80 // Dispatch commands specified on the command line
81 if (!ProcessShellCommand(cmdInfo))
84 // The main window has been initialized, so show and update it.
85 pMainFrame->ShowWindow(m_nCmdShow);
86 pMainFrame->UpdateWindow();
92 /////////////////////////////////////////////////////////////////////////////
93 // CGeometryApp commands
95 //===================================================
97 CFrameWnd* CGeometryApp::CreateView2D(CGeometryDoc* pDoc )
100 ASSERT_VALID(pDocTemplateForView2d);
101 CRuntimeClass * pViewClass = RUNTIME_CLASS(CGeometryView2D);
102 ASSERT(pViewClass != (CRuntimeClass *)NULL );
103 // Create a new frame window
104 CFrameWnd* pNewFrame = pDocTemplateForView2d->CreateNewFrame(pDoc, NULL);
105 pDocTemplateForView2d->InitialUpdateFrame(pNewFrame, pDoc);
109 BOOL CGeometryApp::IsViewExisting(CDocument * pDoc, CRuntimeClass * pViewClass, CView * & pView)
112 ASSERT(pViewClass != (CRuntimeClass *)NULL );
114 POSITION position = pDoc->GetFirstViewPosition();
115 while (position != (POSITION)NULL)
117 CView* pCurrentView = pDoc->GetNextView(position);
118 ASSERT_VALID(pCurrentView);
119 if (pCurrentView->IsKindOf(pViewClass))
121 pView = pCurrentView;