1 // OCCDemo.cpp : Defines the class behaviors for the application.
8 #include "OCCDemoDoc.h"
9 #include "OCCDemoView.h"
13 static char THIS_FILE[] = __FILE__;
16 /////////////////////////////////////////////////////////////////////////////
19 BEGIN_MESSAGE_MAP(COCCDemoApp, CWinApp)
20 //{{AFX_MSG_MAP(COCCDemoApp)
21 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
23 // Standard file based document commands
26 /////////////////////////////////////////////////////////////////////////////
27 // COCCDemoApp construction
29 COCCDemoApp::COCCDemoApp()
31 // TODO: add construction code here,
32 // Place all significant initialization in InitInstance
36 Handle(Aspect_DisplayConnection) aDisplayConnection;
37 myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
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.
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"));
65 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
67 // Register the application's document templates. Document templates
68 // serve as the connection between documents, frame windows and views.
70 CSingleDocTemplate* pDocTemplate;
71 pDocTemplate = new CSingleDocTemplate(
73 RUNTIME_CLASS(COCCDemoDoc),
74 RUNTIME_CLASS(CMainFrame), // main SDI frame window
75 RUNTIME_CLASS(COCCDemoView));
76 AddDocTemplate(pDocTemplate);
79 // Parse command line for standard shell commands, DDE, file open
80 CCommandLineInfo cmdInfo;
81 ParseCommandLine(cmdInfo);
83 // Dispatch commands specified on the command line
84 if (!ProcessShellCommand(cmdInfo))
88 // Create result dialog
90 CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
91 COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
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");
98 aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
99 aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
100 aDoc->GetResultDialog()->Initialize();
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);
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);
115 m_pMainWnd->ShowWindow(SW_SHOW);
116 m_pMainWnd->UpdateWindow();
117 m_pMainWnd->SetFocus();
124 /////////////////////////////////////////////////////////////////////////////
125 // CAboutDlg dialog used for App About
127 class CAboutDlg : public CDialog
133 //{{AFX_DATA(CAboutDlg)
134 enum { IDD = IDD_ABOUTBOX };
137 // ClassWizard generated virtual function overrides
138 //{{AFX_VIRTUAL(CAboutDlg)
140 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
145 //{{AFX_MSG(CAboutDlg)
146 // No message handlers
148 DECLARE_MESSAGE_MAP()
151 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
153 //{{AFX_DATA_INIT(CAboutDlg)
157 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
159 CDialog::DoDataExchange(pDX);
160 //{{AFX_DATA_MAP(CAboutDlg)
164 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
165 //{{AFX_MSG_MAP(CAboutDlg)
166 // No message handlers
170 // App command to run the dialog
171 void COCCDemoApp::OnAppAbout()
177 /////////////////////////////////////////////////////////////////////////////
178 // COCCDemoApp message handlers