2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: VTBFileUtil2.cxx,v 1.2 2003/08/16 04:56:17 douglas Exp $ |
5 |
> |
// $Id: VTBFileUtil2.cxx,v 1.3 2003/08/16 06:44:42 douglas Exp $ |
6 |
|
|
7 |
|
#include "VTBFileUtil2.h" |
8 |
|
|
17 |
|
string programVersion = "2.0alpha"; |
18 |
|
|
19 |
|
HICON icon; |
20 |
< |
|
21 |
< |
enum Mode { none, disc, scan }; |
20 |
> |
Mode choiceMode = none; |
21 |
> |
bool choiceAlways = false; |
22 |
|
|
23 |
|
INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l); |
24 |
|
INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l); |
25 |
+ |
INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l); |
26 |
|
|
27 |
|
inline void arguments(vector<string>& args, const string& command) |
28 |
|
{ |
83 |
|
DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version); |
84 |
|
} |
85 |
|
|
86 |
+ |
inline void choice(Mode& mode, HINSTANCE instance, HWND parent) |
87 |
+ |
{ |
88 |
+ |
DialogBox(instance, MAKEINTRESOURCE(IDD_CHOICE), parent, choice); |
89 |
+ |
|
90 |
+ |
mode = choiceMode; |
91 |
+ |
} |
92 |
+ |
|
93 |
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR |
94 |
|
lpCmdLine, int nShowCmd) |
95 |
|
{ |
96 |
|
vector<string> args; |
97 |
|
|
98 |
+ |
InitCommonControls(); |
99 |
|
arguments(args, GetCommandLine()); |
100 |
|
|
101 |
|
program = args[0]; |
131 |
|
debug = true; |
132 |
|
|
133 |
|
munge(); |
134 |
+ |
cerr.setf(ios_base::boolalpha); |
135 |
|
} |
136 |
|
} |
137 |
+ |
else |
138 |
+ |
{ |
139 |
+ |
string message = "Unknown argument: " + args[index]; |
140 |
+ |
|
141 |
+ |
MessageBox(NULL, message.c_str(), programName.c_str(), |
142 |
+ |
MB_ICONWARNING); |
143 |
+ |
} |
144 |
|
} |
145 |
|
|
146 |
|
if (debug) |
168 |
|
|
169 |
|
if (mode == none) |
170 |
|
{ |
171 |
< |
// |
171 |
> |
choice(mode, hInstance); |
172 |
> |
|
173 |
> |
if (debug) |
174 |
> |
{ |
175 |
> |
cerr << "mode = "; |
176 |
> |
|
177 |
> |
switch (mode) |
178 |
> |
{ |
179 |
> |
case none: |
180 |
> |
cerr << "none"; |
181 |
> |
break; |
182 |
> |
case disc: |
183 |
> |
cerr << "disc"; |
184 |
> |
break; |
185 |
> |
case scan: |
186 |
> |
cerr << "scan"; |
187 |
> |
break; |
188 |
> |
default: |
189 |
> |
cerr << mode; |
190 |
> |
break; |
191 |
> |
} |
192 |
> |
|
193 |
> |
cerr << "\n"; |
194 |
> |
} |
195 |
|
} |
196 |
|
|
197 |
|
if (mode == disc) |
198 |
|
{ |
199 |
< |
// |
199 |
> |
MessageBox(NULL, "Disc Browse mode", programName.c_str(), |
200 |
> |
MB_ICONINFORMATION); |
201 |
|
} |
202 |
|
else if (mode == scan) |
203 |
|
{ |
204 |
< |
// |
204 |
> |
MessageBox(NULL, "Scan Utility mode", programName.c_str(), |
205 |
> |
MB_ICONINFORMATION); |
206 |
|
} |
207 |
|
|
208 |
|
if (debug) |
262 |
|
SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str())); |
263 |
|
{ |
264 |
|
ostringstream version; |
265 |
+ |
|
266 |
|
version << programName << " ( " << programVersion << " )\n\n" |
267 |
|
<< "Copyright © 2003, Douglas Thrift.\n"; |
268 |
|
|
278 |
|
EndDialog(dialog, w); |
279 |
|
return TRUE; |
280 |
|
default: |
281 |
+ |
break; |
282 |
+ |
} |
283 |
+ |
break; |
284 |
+ |
} |
285 |
+ |
|
286 |
+ |
return FALSE; |
287 |
+ |
} |
288 |
+ |
|
289 |
+ |
INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
290 |
+ |
{ |
291 |
+ |
switch (msg) |
292 |
+ |
{ |
293 |
+ |
case WM_INITDIALOG: |
294 |
+ |
center(dialog); |
295 |
+ |
SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon)); |
296 |
+ |
SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str())); |
297 |
+ |
break; |
298 |
+ |
case WM_COMMAND: |
299 |
+ |
switch (LOWORD(w)) |
300 |
+ |
{ |
301 |
+ |
case IDC_CHOICE_DISC: |
302 |
+ |
choiceMode = disc; |
303 |
+ |
if (debug) cerr << "choiceMode = disc\n"; |
304 |
+ |
EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE); |
305 |
+ |
EnableWindow(GetDlgItem(dialog, IDOK), TRUE); |
306 |
+ |
break; |
307 |
+ |
case IDC_CHOICE_SCAN: |
308 |
+ |
choiceMode = scan; |
309 |
+ |
if (debug) cerr << "choiceMode = scan\n"; |
310 |
+ |
EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE); |
311 |
+ |
EnableWindow(GetDlgItem(dialog, IDOK), TRUE); |
312 |
+ |
break; |
313 |
+ |
case IDC_CHOICE_ALWAYS: |
314 |
+ |
choiceAlways = !choiceAlways; |
315 |
+ |
if (debug) cerr << "choiceAlways = " << choiceAlways << "\n"; |
316 |
+ |
break; |
317 |
+ |
case IDCANCEL: |
318 |
+ |
choiceMode = none; |
319 |
+ |
case IDOK: |
320 |
+ |
EndDialog(dialog, w); |
321 |
+ |
return TRUE; |
322 |
+ |
default: |
323 |
|
break; |
324 |
|
} |
325 |
|
break; |