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() : OCC_App()
34 Handle(Aspect_DisplayConnection) aDisplayConnection;
35 myGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
37 catch (Standard_Failure)
39 AfxMessageBox ("Fatal Error During Graphic Initialisation");
43 /////////////////////////////////////////////////////////////////////////////
44 // The one and only COCCDemoApp object
48 /////////////////////////////////////////////////////////////////////////////
49 // COCCDemoApp initialization
51 BOOL COCCDemoApp::InitInstance()
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.
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"));
63 LoadStdProfileSettings(); // Load standard INI file options (including MRU)
65 // Register the application's document templates. Document templates
66 // serve as the connection between documents, frame windows and views.
68 CSingleDocTemplate* pDocTemplate;
69 pDocTemplate = new CSingleDocTemplate(
71 RUNTIME_CLASS(COCCDemoDoc),
72 RUNTIME_CLASS(CMainFrame), // main SDI frame window
73 RUNTIME_CLASS(COCCDemoView));
74 AddDocTemplate(pDocTemplate);
77 // Parse command line for standard shell commands, DDE, file open
78 CCommandLineInfo cmdInfo;
79 ParseCommandLine(cmdInfo);
81 // Dispatch commands specified on the command line
82 if (!ProcessShellCommand(cmdInfo))
86 // Create result dialog
88 CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
89 COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
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");
96 aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
97 aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
98 aDoc->GetResultDialog()->Initialize();
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);
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);
113 m_pMainWnd->ShowWindow(SW_SHOW);
114 m_pMainWnd->UpdateWindow();
115 m_pMainWnd->SetFocus();
122 /////////////////////////////////////////////////////////////////////////////
123 // CAboutDlg dialog used for App About
125 class CAboutDlg : public CDialog
131 //{{AFX_DATA(CAboutDlg)
132 enum { IDD = IDD_ABOUTBOX };
135 // ClassWizard generated virtual function overrides
136 //{{AFX_VIRTUAL(CAboutDlg)
138 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
143 //{{AFX_MSG(CAboutDlg)
144 // No message handlers
146 DECLARE_MESSAGE_MAP()
149 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
151 //{{AFX_DATA_INIT(CAboutDlg)
155 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
157 CDialog::DoDataExchange(pDX);
158 //{{AFX_DATA_MAP(CAboutDlg)
162 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
163 //{{AFX_MSG_MAP(CAboutDlg)
164 // No message handlers
168 // App command to run the dialog
169 void COCCDemoApp::OnAppAbout()
175 /////////////////////////////////////////////////////////////////////////////
176 // COCCDemoApp message handlers