7fd59977 |
1 | // OCC_BaseApp.cpp: implementation of the OCC_BaseApp class. |
2 | // |
3 | ////////////////////////////////////////////////////////////////////// |
4 | |
5 | #include <stdafx.h> |
6 | |
7 | #include "OCC_BaseApp.h" |
8 | |
9 | #include <res\OCC_Resource.h> |
10 | |
11 | #include <Standard_Version.hxx> |
2b442de5 |
12 | #include <OSD.hxx> |
7fd59977 |
13 | |
14 | ///////////////////////////////////////////////////////////////////////////// |
15 | // OCC_BaseApp |
16 | |
17 | BEGIN_MESSAGE_MAP(OCC_BaseApp, CWinApp) |
18 | //{{AFX_MSG_MAP(OCC_BaseApp) |
19 | ON_COMMAND(ID_APP_ABOUT, OnAppAbout) |
20 | // NOTE - the ClassWizard will add and remove mapping macros here. |
21 | // DO NOT EDIT what you see in these blocks of generated code! |
22 | //}}AFX_MSG_MAP |
23 | // Standard file based document commands |
24 | ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) |
25 | ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) |
26 | END_MESSAGE_MAP() |
27 | |
28 | ///////////////////////////////////////////////////////////////////////////// |
29 | // OCC_BaseApp construction |
30 | |
31 | OCC_BaseApp::OCC_BaseApp() |
32 | { |
2b442de5 |
33 | OSD::SetSignal(Standard_True); |
7fd59977 |
34 | SampleName = ""; |
35 | SetSamplePath(NULL); |
36 | } |
37 | |
38 | |
39 | void OCC_BaseApp::SetSamplePath(LPCTSTR aPath) |
40 | { |
41 | char AbsoluteExecutableFileName[MAX_PATH+1]; |
42 | HMODULE hModule = GetModuleHandle(NULL); |
43 | GetModuleFileName(hModule, AbsoluteExecutableFileName, MAX_PATH); |
44 | |
45 | SamplePath = CString(AbsoluteExecutableFileName); |
46 | int index = SamplePath.ReverseFind('\\'); |
47 | SamplePath.Delete(index+1, SamplePath.GetLength() - index - 1); |
48 | if (aPath == NULL) |
49 | SamplePath += ".."; |
50 | else{ |
51 | CString aCInitialDir(aPath); |
52 | SamplePath += "..\\" + aCInitialDir; |
53 | } |
54 | } |
55 | ///////////////////////////////////////////////////////////////////////////// |
56 | // CAboutDlgStd dialog used for App About |
57 | |
58 | class CAboutDlgStd : public CDialog |
59 | { |
60 | public: |
61 | CAboutDlgStd(); |
62 | BOOL OnInitDialog(); |
63 | |
64 | // Dialog Data |
65 | //{{AFX_DATA(CAboutDlgStd) |
66 | enum { IDD = IDD_OCC_ABOUTBOX }; |
67 | //}}AFX_DATA |
68 | |
69 | // ClassWizard generated virtual function overrides |
70 | //{{AFX_VIRTUAL(CAboutDlgStd) |
71 | protected: |
72 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
73 | //}}AFX_VIRTUAL |
74 | |
75 | |
76 | // Implementation |
77 | protected: |
78 | //{{AFX_MSG(CAboutDlgStd) |
79 | // No message handlers |
80 | //}}AFX_MSG |
81 | DECLARE_MESSAGE_MAP() |
82 | }; |
83 | |
84 | CAboutDlgStd::CAboutDlgStd() : CDialog(CAboutDlgStd::IDD) |
85 | { |
86 | //{{AFX_DATA_INIT(CAboutDlgStd) |
87 | //}}AFX_DATA_INIT |
88 | } |
89 | |
90 | void CAboutDlgStd::DoDataExchange(CDataExchange* pDX) |
91 | { |
92 | CDialog::DoDataExchange(pDX); |
93 | //{{AFX_DATA_MAP(CAboutDlgStd) |
94 | //}}AFX_DATA_MAP |
95 | } |
96 | |
97 | BEGIN_MESSAGE_MAP(CAboutDlgStd, CDialog) |
98 | //{{AFX_MSG_MAP(CAboutDlgStd) |
99 | // No message handlers |
100 | //}}AFX_MSG_MAP |
101 | END_MESSAGE_MAP() |
102 | |
103 | BOOL CAboutDlgStd::OnInitDialog(){ |
104 | CWnd* Title = GetDlgItem(IDC_ABOUTBOX_TITLE); |
105 | |
106 | CString About = "About "; |
107 | CString Sample = "Sample "; |
108 | CString SampleName = ((OCC_BaseApp*)AfxGetApp())->GetSampleName(); |
109 | CString Cascade = ", Open CASCADE Technology "; |
110 | CString Version = OCC_VERSION_STRING; |
111 | |
112 | CString strTitle = Sample + SampleName + Cascade + Version; |
113 | CString dlgTitle = About + SampleName; |
114 | |
115 | Title->SetWindowText(strTitle); |
116 | SetWindowText(dlgTitle); |
117 | |
118 | CenterWindow(); |
119 | |
120 | return TRUE; |
121 | } |
122 | |
123 | // App command to run the dialog |
124 | void OCC_BaseApp::OnAppAbout() |
125 | { |
126 | CAboutDlgStd aboutDlg; |
127 | aboutDlg.DoModal(); |
128 | } |
129 | |
130 | LPCTSTR OCC_BaseApp::GetSampleName() |
131 | { |
132 | return SampleName; |
133 | } |
134 | |
135 | LPCTSTR OCC_BaseApp::GetInitDataDir() |
136 | { |
137 | return (LPCTSTR) SamplePath; |
138 | } |
139 | |
140 | void OCC_BaseApp::SetSampleName(LPCTSTR Name) |
141 | { |
142 | SampleName = Name; |
143 | } |