6fbb30da22ea77059856c85ce5e7e184cc4a531d
[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() : OCC_App()
30 {
31   SampleName = "";
32   try
33   {
34     Handle(Aspect_DisplayConnection) aDisplayConnection;
35     myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
36   }
37   catch (Standard_Failure)
38   {
39     AfxMessageBox ("Fatal Error During Graphic Initialisation");
40   }
41 }
42
43 /////////////////////////////////////////////////////////////////////////////
44 // The one and only COCCDemoApp object
45
46 COCCDemoApp theApp;
47
48 /////////////////////////////////////////////////////////////////////////////
49 // COCCDemoApp initialization
50
51 BOOL COCCDemoApp::InitInstance()
52 {
53         // Standard initialization
54         // If you are not using these features and wish to reduce the size
55         //  of your final executable, you should remove from the following
56         //  the specific initialization routines you do not need.
57
58         // Change the registry key under which our settings are stored.
59         // TODO: You should modify this string to be something appropriate
60         // such as the name of your company or organization.
61         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
62
63         LoadStdProfileSettings();  // Load standard INI file options (including MRU)
64
65         // Register the application's document templates.  Document templates
66         //  serve as the connection between documents, frame windows and views.
67
68         CSingleDocTemplate* pDocTemplate;
69         pDocTemplate = new CSingleDocTemplate(
70                 IDR_MAINFRAME,
71                 RUNTIME_CLASS(COCCDemoDoc),
72                 RUNTIME_CLASS(CMainFrame),       // main SDI frame window
73                 RUNTIME_CLASS(COCCDemoView));
74         AddDocTemplate(pDocTemplate);
75
76
77         // Parse command line for standard shell commands, DDE, file open
78         CCommandLineInfo cmdInfo;
79         ParseCommandLine(cmdInfo);
80
81         // Dispatch commands specified on the command line
82         if (!ProcessShellCommand(cmdInfo))
83                 return FALSE;
84
85         
86   // Create result dialog
87   AfxInitRichEdit();
88   CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
89   COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
90
91   // pass cFrame->GetDesktopWindow() as parent to have an independent dialog
92   // pass cFrame as parent to have the result dialog always above the main window
93   if (!aDoc->GetResultDialog()->Create(CResultDialog::IDD, cFrame->GetDesktopWindow()))
94     TRACE0("Failed to create result dialog\n");
95
96   aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
97         aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
98   aDoc->GetResultDialog()->Initialize();
99
100   // resize the result dialog, so no clipping occures when user
101   // resizes the dialog manually
102   // position the result dialog to the left bottom corner of the view
103   CRect aDlgRect, aViewRect;
104   aDoc->GetResultDialog()->GetWindowRect(&aDlgRect);
105   cFrame->GetActiveView()->GetWindowRect(&aViewRect);
106
107   int x = aViewRect.left;
108   int y = aViewRect.bottom - aDlgRect.Size().cy;
109   int cx = aDlgRect.Size().cx+1;
110   int cy = aDlgRect.Size().cy+1;
111   aDoc->GetResultDialog()->SetWindowPos(NULL, x, y, cx, cy, SWP_NOREDRAW | SWP_NOZORDER);
112
113         m_pMainWnd->ShowWindow(SW_SHOW);
114         m_pMainWnd->UpdateWindow();
115   m_pMainWnd->SetFocus();
116   aDoc->Start();
117
118         return TRUE;
119 }
120
121 /*
122 /////////////////////////////////////////////////////////////////////////////
123 // CAboutDlg dialog used for App About
124
125 class CAboutDlg : public CDialog
126 {
127 public:
128         CAboutDlg();
129
130 // Dialog Data
131         //{{AFX_DATA(CAboutDlg)
132         enum { IDD = IDD_ABOUTBOX };
133         //}}AFX_DATA
134
135         // ClassWizard generated virtual function overrides
136         //{{AFX_VIRTUAL(CAboutDlg)
137         protected:
138         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
139         //}}AFX_VIRTUAL
140
141 // Implementation
142 protected:
143         //{{AFX_MSG(CAboutDlg)
144                 // No message handlers
145         //}}AFX_MSG
146         DECLARE_MESSAGE_MAP()
147 };
148
149 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
150 {
151         //{{AFX_DATA_INIT(CAboutDlg)
152         //}}AFX_DATA_INIT
153 }
154
155 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
156 {
157         CDialog::DoDataExchange(pDX);
158         //{{AFX_DATA_MAP(CAboutDlg)
159         //}}AFX_DATA_MAP
160 }
161
162 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
163         //{{AFX_MSG_MAP(CAboutDlg)
164                 // No message handlers
165         //}}AFX_MSG_MAP
166 END_MESSAGE_MAP()
167
168 // App command to run the dialog
169 void COCCDemoApp::OnAppAbout()
170 {
171         CAboutDlg aboutDlg;
172         aboutDlg.DoModal();
173 }
174
175 /////////////////////////////////////////////////////////////////////////////
176 // COCCDemoApp message handlers
177
178 */