1 // ImportExportApp.cpp : Defines the class behaviors for the application.
6 #include "ImportExportApp.h"
8 #include "OCC_MainFrame.h"
9 #include "OCC_3dChildFrame.h"
10 #include "ImportExportDoc.h"
11 #include <OCC_3dView.h>
12 #include <res\resource.h>
14 BEGIN_MESSAGE_MAP(CImportExportApp, OCC_3dApp)
15 //{{AFX_MSG_MAP(CSerializeApp)
16 ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
20 /////////////////////////////////////////////////////////////////////////////
21 // CImportExportApp construction
23 CImportExportApp::CImportExportApp()
25 // Set the local system units
27 { UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); }
28 catch (Standard_Failure)
30 AfxMessageBox("Fatal Error in units initialisation");
32 SampleName = "ImportExport"; //for about dialog
35 /////////////////////////////////////////////////////////////////////////////
36 // The one and only CImportExportApp object
38 CImportExportApp theApp;
40 /////////////////////////////////////////////////////////////////////////////
41 // CImportExportApp initialization
43 BOOL CImportExportApp::InitInstance()
45 AfxEnableControlContainer();
47 // Standard initialization
48 // If you are not using these features and wish to reduce the size
49 // of your final executable, you should remove from the following
50 // the specific initialization routines you do not need.
52 // Change the registry key under which our settings are stored.
53 // You should modify this string to be something appropriate
54 // such as the name of your company or organization.
55 // Modified by CasCade :
56 SetRegistryKey(_T("Local CasCade Applications"));
58 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
60 // Register the application's document templates. Document templates
61 // serve as the connection between documents, frame windows and views.
63 CMultiDocTemplate* pDocTemplate;
64 pDocTemplate = new CMultiDocTemplate(
66 RUNTIME_CLASS(CImportExportDoc),
67 RUNTIME_CLASS(OCC_3dChildFrame),
68 RUNTIME_CLASS(OCC_3dView));
69 AddDocTemplate(pDocTemplate);
71 // create main MDI Frame window
72 OCC_MainFrame* pMainFrame = new OCC_MainFrame(with_AIS_TB);
73 if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
75 m_pMainWnd = pMainFrame;
77 // Parse command line for standard shell commands, DDE, file open
78 CCommandLineInfo cmdInfo;
79 ParseCommandLine(cmdInfo);
81 // Dispatch commands specified on the command line
82 if (!ProcessShellCommand(cmdInfo))
85 // The main window has been initialized, so show and update it.
86 pMainFrame->ShowWindow(m_nCmdShow);
87 pMainFrame->UpdateWindow();
92 CDocument* CImportExportApp::OpenDocumentFile(LPCTSTR lpszFileName)
96 if (!cf.Open(lpszFileName,CFile::modeReadWrite)){
97 AfxMessageBox("File not found!");
101 return CWinApp::OpenDocumentFile(lpszFileName);
104 void CImportExportApp::OnFileOpen()
106 CFileDialog dlg(TRUE,
109 OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
114 CString initdir(((OCC_BaseApp*) AfxGetApp())->GetInitDataDir());
117 dlg.m_ofn.lpstrInitialDir = initdir;
122 POSITION pos = GetFirstDocTemplatePosition();
124 CDocTemplate* pTemplate = GetNextDocTemplate(pos);
125 CString strFilterExt, strFilterName;
126 if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) &&
127 !strFilterExt.IsEmpty() &&
128 pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
129 !strFilterName.IsEmpty()) {
131 strFilter += strFilterName;
132 ASSERT(!strFilter.IsEmpty()); // must have a file type name
133 strFilter += (TCHAR)'\0'; // next string please
134 strFilter += (TCHAR)'*';
135 strFilter += strFilterExt;
136 strFilter += (TCHAR)'\0'; // next string please
137 dlg.m_ofn.nMaxCustFilter++;
139 // append the "*.*" all files filter
141 VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
142 strFilter += allFilter;
143 strFilter += (TCHAR)'\0'; // next string please
144 strFilter += _T("*.*");
145 strFilter += (TCHAR)'\0'; // last string
146 dlg.m_ofn.nMaxCustFilter++;
147 dlg.m_ofn.lpstrFilter = strFilter;
149 if (dlg.DoModal() == IDOK)
151 AfxGetApp()->OpenDocumentFile(dlg.GetPathName());