Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / mfc / occtdemo / Common / WNT / OCCDemo.cpp
CommitLineData
7fd59977 1// OCCDemo.cpp : Defines the class behaviors for the application.
2//
3
4#include "stdafx.h"
5#include "OCCDemo.h"
6
7#include "MainFrm.h"
8#include "OCCDemoDoc.h"
9#include "OCCDemoView.h"
10
11#include <Standard_Version.hxx>
12
13#ifdef _DEBUG
14#undef THIS_FILE
15static char THIS_FILE[] = __FILE__;
16#endif
17
18/////////////////////////////////////////////////////////////////////////////
19// COCCDemoApp
20
21BEGIN_MESSAGE_MAP(COCCDemoApp, CWinApp)
22 //{{AFX_MSG_MAP(COCCDemoApp)
23 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
24 //}}AFX_MSG_MAP
25 // Standard file based document commands
26END_MESSAGE_MAP()
27
28/////////////////////////////////////////////////////////////////////////////
29// COCCDemoApp construction
30
31COCCDemoApp::COCCDemoApp()
32{
33 // TODO: add construction code here,
34 // Place all significant initialization in InitInstance
35 try
36 {
37 myGraphicDevice = new Graphic3d_WNTGraphicDevice;
38 }
39 catch(Standard_Failure)
40 {
41 AfxMessageBox("Fatal Error During Graphic Initialisation");
42 }
43}
44
45/////////////////////////////////////////////////////////////////////////////
46// The one and only COCCDemoApp object
47
48COCCDemoApp theApp;
49
50/////////////////////////////////////////////////////////////////////////////
51// COCCDemoApp initialization
52
53BOOL COCCDemoApp::InitInstance()
54{
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.
59
60#ifdef _AFXDLL
61 Enable3dControls(); // Call this when using MFC in a shared DLL
62#else
63 Enable3dControlsStatic(); // Call this when linking to MFC statically
64#endif
65
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"));
70
71 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
72
73 // Register the application's document templates. Document templates
74 // serve as the connection between documents, frame windows and views.
75
76 CSingleDocTemplate* pDocTemplate;
77 pDocTemplate = new CSingleDocTemplate(
78 IDR_MAINFRAME,
79 RUNTIME_CLASS(COCCDemoDoc),
80 RUNTIME_CLASS(CMainFrame), // main SDI frame window
81 RUNTIME_CLASS(COCCDemoView));
82 AddDocTemplate(pDocTemplate);
83
84 // Parse command line for standard shell commands, DDE, file open
85 CCommandLineInfo cmdInfo;
86 ParseCommandLine(cmdInfo);
87
88 // Dispatch commands specified on the command line
89 if (!ProcessShellCommand(cmdInfo))
90 return FALSE;
91
92 // Create result dialog
93 AfxInitRichEdit();
94 CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
95 COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
96
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");
101
102 aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
103 aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
104 aDoc->GetResultDialog()->Initialize();
105
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);
112
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);
118
119 m_pMainWnd->ShowWindow(SW_SHOW);
120 m_pMainWnd->UpdateWindow();
121 m_pMainWnd->SetFocus();
122 aDoc->Start();
123
124 return TRUE;
125}
126
127
128/////////////////////////////////////////////////////////////////////////////
129// CAboutDlg dialog used for App About
130
131class CAboutDlg : public CDialog
132{
133public:
134 CAboutDlg();
135 BOOL OnInitDialog();
136
137// Dialog Data
138 //{{AFX_DATA(CAboutDlg)
139 enum { IDD = IDD_ABOUTBOX };
140 //}}AFX_DATA
141
142 // ClassWizard generated virtual function overrides
143 //{{AFX_VIRTUAL(CAboutDlg)
144 protected:
145 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
146 //}}AFX_VIRTUAL
147
148// Implementation
149protected:
150 //{{AFX_MSG(CAboutDlg)
151 // No message handlers
152 //}}AFX_MSG
153 DECLARE_MESSAGE_MAP()
154};
155
156CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
157{
158 //{{AFX_DATA_INIT(CAboutDlg)
159 //}}AFX_DATA_INIT
160}
161
162void CAboutDlg::DoDataExchange(CDataExchange* pDX)
163{
164 CDialog::DoDataExchange(pDX);
165 //{{AFX_DATA_MAP(CAboutDlg)
166 //}}AFX_DATA_MAP
167}
168
169BOOL CAboutDlg::OnInitDialog(){
170
171 CWnd* TitleWnd = GetDlgItem(IDC_ABOUTBOX_TITLE);
172 CString TitleString;
173 TitleWnd->GetWindowText(TitleString);
174
175 CString OCC_Version = OCC_VERSION_STRING;
176 TitleString = TitleString + OCC_Version;
177
178 TitleWnd->SetWindowText(TitleString);
179
180 CenterWindow();
181
182 return TRUE;
183}
184
185
186BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
187 //{{AFX_MSG_MAP(CAboutDlg)
188 // No message handlers
189 //}}AFX_MSG_MAP
190END_MESSAGE_MAP()
191
192// App command to run the dialog
193void COCCDemoApp::OnAppAbout()
194{
195 CAboutDlg aboutDlg;
196 aboutDlg.DoModal();
197}
198
199/////////////////////////////////////////////////////////////////////////////
200// COCCDemoApp message handlers
201