// OcafApp.cpp : Defines the class behaviors for the application. // #include "StdAfx.h" #include "OcafApp.h" #include "OcafMainFrm.h" #include #include "OcafDoc.h" #include #include "direct.h" #include ///////////////////////////////////////////////////////////////////////////// // COcafApp BEGIN_MESSAGE_MAP(COcafApp, CWinApp) //{{AFX_MSG_MAP(COcafApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP // Standard file based document commands ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) // ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // COcafApp construction COcafApp::COcafApp() { // CasCade : SetSamplePath("10_Ocaf"); CString initdir(((OCC_BaseApp*) AfxGetApp())->GetInitDataDir()); CString resstr = "CSF_ResourcesDefaults=" + initdir; SetEnvironmentVariable ( "CSF_ResourcesDefaults", initdir); putenv (resstr); OSD_Environment aR(TCollection_AsciiString("CSF_ResourcesDefaults"), TCollection_AsciiString((Standard_CString) (LPCTSTR) initdir)); aR.Build(); cout<LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // COcafApp commands BOOL COcafApp::IsViewExisting(CDocument * pDoc, CRuntimeClass * pViewClass, CView * & pView) { ASSERT_VALID(pDoc); ASSERT(pViewClass != (CRuntimeClass *)NULL ); POSITION position = pDoc->GetFirstViewPosition(); while (position != (POSITION)NULL) { CView* pCurrentView = pDoc->GetNextView(position); ASSERT_VALID(pCurrentView); if (pCurrentView->IsKindOf(pViewClass)) { pView = pCurrentView; return TRUE; } } return FALSE; } ///////////////////////////////////////////////////////////////////////////// // COCcafApp message handlers //================================================================ // Function : COcafApp::OnFileOpen() ///Purpose : //================================================================ void COcafApp::OnFileOpen() { CFileDialog aDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, "OCAFSample(STA) (*.sta)|*.sta|OCAFSample(XML) (*.xml)|*.xml|OCAFSample(Binary) (*.cbf)|*.cbf||"); if (aDlg.DoModal() != IDOK) return; LPTSTR lpszFileName = new TCHAR[aDlg.GetFileName().GetLength()+1]; _tcscpy(lpszFileName, aDlg.GetFileName()); OpenDocumentFile(lpszFileName); }