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() : OCC_App()
20 SampleName = "Geometry"; //for about dialog
21 SetSamplePath ("..\\..\\01_Geometry");
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();
91 /////////////////////////////////////////////////////////////////////////////
92 // CGeometryApp commands
94 //===================================================
96 CFrameWnd* CGeometryApp::CreateView2D(CGeometryDoc* pDoc )
99 ASSERT_VALID(pDocTemplateForView2d);
100 CRuntimeClass * pViewClass = RUNTIME_CLASS(CGeometryView2D);
101 ASSERT(pViewClass != (CRuntimeClass *)NULL );
102 // Create a new frame window
103 CFrameWnd* pNewFrame = pDocTemplateForView2d->CreateNewFrame(pDoc, NULL);
104 pDocTemplateForView2d->InitialUpdateFrame(pNewFrame, pDoc);
108 BOOL CGeometryApp::IsViewExisting(CDocument * pDoc, CRuntimeClass * pViewClass, CView * & pView)
111 ASSERT(pViewClass != (CRuntimeClass *)NULL );
113 POSITION position = pDoc->GetFirstViewPosition();
114 while (position != (POSITION)NULL)
116 CView* pCurrentView = pDoc->GetNextView(position);
117 ASSERT_VALID(pCurrentView);
118 if (pCurrentView->IsKindOf(pViewClass))
120 pView = pCurrentView;