1 // OCCDemo.cpp : Defines the class behaviors for the application.
8 #include "OCCDemoDoc.h"
9 #include "OCCDemoView.h"
11 #include <Standard_Version.hxx>
15 static char THIS_FILE[] = __FILE__;
18 /////////////////////////////////////////////////////////////////////////////
21 BEGIN_MESSAGE_MAP(COCCDemoApp, CWinApp)
22 //{{AFX_MSG_MAP(COCCDemoApp)
23 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
25 // Standard file based document commands
28 /////////////////////////////////////////////////////////////////////////////
29 // COCCDemoApp construction
31 COCCDemoApp::COCCDemoApp()
33 // TODO: add construction code here,
34 // Place all significant initialization in InitInstance
37 myGraphicDevice = new Graphic3d_WNTGraphicDevice;
39 catch(Standard_Failure)
41 AfxMessageBox("Fatal Error During Graphic Initialisation");
45 /////////////////////////////////////////////////////////////////////////////
46 // The one and only COCCDemoApp object
50 /////////////////////////////////////////////////////////////////////////////
51 // COCCDemoApp initialization
53 BOOL COCCDemoApp::InitInstance()
55 // Standard initialization
56 // If you are not using these features and wish to reduce the size
57 // of your final executable, you should remove from the following
58 // the specific initialization routines you do not need.
61 Enable3dControls(); // Call this when using MFC in a shared DLL
63 Enable3dControlsStatic(); // Call this when linking to MFC statically
66 // Change the registry key under which our settings are stored.
67 // TODO: You should modify this string to be something appropriate
68 // such as the name of your company or organization.
69 SetRegistryKey(_T("Local AppWizard-Generated Applications"));
71 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
73 // Register the application's document templates. Document templates
74 // serve as the connection between documents, frame windows and views.
76 CSingleDocTemplate* pDocTemplate;
77 pDocTemplate = new CSingleDocTemplate(
79 RUNTIME_CLASS(COCCDemoDoc),
80 RUNTIME_CLASS(CMainFrame), // main SDI frame window
81 RUNTIME_CLASS(COCCDemoView));
82 AddDocTemplate(pDocTemplate);
84 // Parse command line for standard shell commands, DDE, file open
85 CCommandLineInfo cmdInfo;
86 ParseCommandLine(cmdInfo);
88 // Dispatch commands specified on the command line
89 if (!ProcessShellCommand(cmdInfo))
92 // Create result dialog
94 CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
95 COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
97 // pass cFrame->GetDesktopWindow() as parent to have an independent dialog
98 // pass cFrame as parent to have the result dialog always above the main window
99 if (!aDoc->GetResultDialog()->Create(CResultDialog::IDD, cFrame->GetDesktopWindow()))
100 TRACE0("Failed to create result dialog\n");
102 aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
103 aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
104 aDoc->GetResultDialog()->Initialize();
106 // resize the result dialog, so no clipping occures when user
107 // resizes the dialog manually
108 // position the result dialog to the left bottom corner of the view
109 CRect aDlgRect, aViewRect;
110 aDoc->GetResultDialog()->GetWindowRect(&aDlgRect);
111 cFrame->GetActiveView()->GetWindowRect(&aViewRect);
113 int x = aViewRect.left;
114 int y = aViewRect.bottom - aDlgRect.Size().cy;
115 int cx = aDlgRect.Size().cx+1;
116 int cy = aDlgRect.Size().cy+1;
117 aDoc->GetResultDialog()->SetWindowPos(NULL, x, y, cx, cy, SWP_NOREDRAW | SWP_NOZORDER);
119 m_pMainWnd->ShowWindow(SW_SHOW);
120 m_pMainWnd->UpdateWindow();
121 m_pMainWnd->SetFocus();
128 /////////////////////////////////////////////////////////////////////////////
129 // CAboutDlg dialog used for App About
131 class CAboutDlg : public CDialog
138 //{{AFX_DATA(CAboutDlg)
139 enum { IDD = IDD_ABOUTBOX };
142 // ClassWizard generated virtual function overrides
143 //{{AFX_VIRTUAL(CAboutDlg)
145 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
150 //{{AFX_MSG(CAboutDlg)
151 // No message handlers
153 DECLARE_MESSAGE_MAP()
156 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
158 //{{AFX_DATA_INIT(CAboutDlg)
162 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
164 CDialog::DoDataExchange(pDX);
165 //{{AFX_DATA_MAP(CAboutDlg)
169 BOOL CAboutDlg::OnInitDialog(){
171 CWnd* TitleWnd = GetDlgItem(IDC_ABOUTBOX_TITLE);
173 TitleWnd->GetWindowText(TitleString);
175 CString OCC_Version = OCC_VERSION_STRING;
176 TitleString = TitleString + OCC_Version;
178 TitleWnd->SetWindowText(TitleString);
186 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
187 //{{AFX_MSG_MAP(CAboutDlg)
188 // No message handlers
192 // App command to run the dialog
193 void COCCDemoApp::OnAppAbout()
199 /////////////////////////////////////////////////////////////////////////////
200 // COCCDemoApp message handlers