0023712: Remove dependency on Aspect_GraphicDevice from Aspect_Window
[occt.git] / samples / mfc / standard / 10_Convert / src / WNT / OCCDemo.cpp
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 #ifdef _DEBUG
12 #undef THIS_FILE
13 static char THIS_FILE[] = __FILE__;
14 #endif
15
16 /////////////////////////////////////////////////////////////////////////////
17 // COCCDemoApp
18
19 BEGIN_MESSAGE_MAP(COCCDemoApp, CWinApp)
20         //{{AFX_MSG_MAP(COCCDemoApp)
21         ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
22         //}}AFX_MSG_MAP
23         // Standard file based document commands
24 END_MESSAGE_MAP()
25
26 /////////////////////////////////////////////////////////////////////////////
27 // COCCDemoApp construction
28
29 COCCDemoApp::COCCDemoApp()
30 {
31         // TODO: add construction code here,
32         // Place all significant initialization in InitInstance
33         SampleName = "";
34   try
35   {
36     Handle(Aspect_DisplayConnection) aDisplayConnection;
37     myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
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
48 COCCDemoApp theApp;
49
50 /////////////////////////////////////////////////////////////////////////////
51 // COCCDemoApp initialization
52
53 BOOL 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         // Change the registry key under which our settings are stored.
61         // TODO: You should modify this string to be something appropriate
62         // such as the name of your company or organization.
63         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
64
65         LoadStdProfileSettings();  // Load standard INI file options (including MRU)
66
67         // Register the application's document templates.  Document templates
68         //  serve as the connection between documents, frame windows and views.
69
70         CSingleDocTemplate* pDocTemplate;
71         pDocTemplate = new CSingleDocTemplate(
72                 IDR_MAINFRAME,
73                 RUNTIME_CLASS(COCCDemoDoc),
74                 RUNTIME_CLASS(CMainFrame),       // main SDI frame window
75                 RUNTIME_CLASS(COCCDemoView));
76         AddDocTemplate(pDocTemplate);
77
78
79         // Parse command line for standard shell commands, DDE, file open
80         CCommandLineInfo cmdInfo;
81         ParseCommandLine(cmdInfo);
82
83         // Dispatch commands specified on the command line
84         if (!ProcessShellCommand(cmdInfo))
85                 return FALSE;
86
87         
88   // Create result dialog
89   AfxInitRichEdit();
90   CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
91   COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
92
93   // pass cFrame->GetDesktopWindow() as parent to have an independent dialog
94   // pass cFrame as parent to have the result dialog always above the main window
95   if (!aDoc->GetResultDialog()->Create(CResultDialog::IDD, cFrame->GetDesktopWindow()))
96     TRACE0("Failed to create result dialog\n");
97
98   aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
99         aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
100   aDoc->GetResultDialog()->Initialize();
101
102   // resize the result dialog, so no clipping occures when user
103   // resizes the dialog manually
104   // position the result dialog to the left bottom corner of the view
105   CRect aDlgRect, aViewRect;
106   aDoc->GetResultDialog()->GetWindowRect(&aDlgRect);
107   cFrame->GetActiveView()->GetWindowRect(&aViewRect);
108
109   int x = aViewRect.left;
110   int y = aViewRect.bottom - aDlgRect.Size().cy;
111   int cx = aDlgRect.Size().cx+1;
112   int cy = aDlgRect.Size().cy+1;
113   aDoc->GetResultDialog()->SetWindowPos(NULL, x, y, cx, cy, SWP_NOREDRAW | SWP_NOZORDER);
114
115         m_pMainWnd->ShowWindow(SW_SHOW);
116         m_pMainWnd->UpdateWindow();
117   m_pMainWnd->SetFocus();
118   aDoc->Start();
119
120         return TRUE;
121 }
122
123 /*
124 /////////////////////////////////////////////////////////////////////////////
125 // CAboutDlg dialog used for App About
126
127 class CAboutDlg : public CDialog
128 {
129 public:
130         CAboutDlg();
131
132 // Dialog Data
133         //{{AFX_DATA(CAboutDlg)
134         enum { IDD = IDD_ABOUTBOX };
135         //}}AFX_DATA
136
137         // ClassWizard generated virtual function overrides
138         //{{AFX_VIRTUAL(CAboutDlg)
139         protected:
140         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
141         //}}AFX_VIRTUAL
142
143 // Implementation
144 protected:
145         //{{AFX_MSG(CAboutDlg)
146                 // No message handlers
147         //}}AFX_MSG
148         DECLARE_MESSAGE_MAP()
149 };
150
151 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
152 {
153         //{{AFX_DATA_INIT(CAboutDlg)
154         //}}AFX_DATA_INIT
155 }
156
157 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
158 {
159         CDialog::DoDataExchange(pDX);
160         //{{AFX_DATA_MAP(CAboutDlg)
161         //}}AFX_DATA_MAP
162 }
163
164 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
165         //{{AFX_MSG_MAP(CAboutDlg)
166                 // No message handlers
167         //}}AFX_MSG_MAP
168 END_MESSAGE_MAP()
169
170 // App command to run the dialog
171 void COCCDemoApp::OnAppAbout()
172 {
173         CAboutDlg aboutDlg;
174         aboutDlg.DoModal();
175 }
176
177 /////////////////////////////////////////////////////////////////////////////
178 // COCCDemoApp message handlers
179
180 */