2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: VTBFileUtil2.cxx,v 1.1 2003/08/16 00:12:57 douglas Exp $ |
5 |
> |
// $Id: VTBFileUtil2.cxx,v 1.2 2003/08/16 04:56:17 douglas Exp $ |
6 |
|
|
7 |
|
#include "VTBFileUtil2.h" |
8 |
|
|
9 |
|
#include <io.h> |
10 |
|
#include <fcntl.h> |
11 |
|
|
12 |
+ |
#include "resource.h" |
13 |
+ |
|
14 |
|
bool debug = false; |
15 |
|
string program; |
16 |
|
string programName = "Vance Thrift and Biller File Utility 2"; |
17 |
< |
unsigned programVersion = 0x00101000; |
17 |
> |
string programVersion = "2.0alpha"; |
18 |
> |
|
19 |
> |
HICON icon; |
20 |
> |
|
21 |
> |
enum Mode { none, disc, scan }; |
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 |
|
|
26 |
|
inline void arguments(vector<string>& args, const string& command) |
27 |
|
{ |
72 |
|
cerr.sync_with_stdio(); |
73 |
|
} |
74 |
|
|
75 |
+ |
inline void usage(HINSTANCE instance, HWND parent) |
76 |
+ |
{ |
77 |
+ |
DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage); |
78 |
+ |
} |
79 |
+ |
|
80 |
+ |
inline void version(HINSTANCE instance, HWND parent) |
81 |
+ |
{ |
82 |
+ |
DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version); |
83 |
+ |
} |
84 |
+ |
|
85 |
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR |
86 |
|
lpCmdLine, int nShowCmd) |
87 |
|
{ |
91 |
|
|
92 |
|
program = args[0]; |
93 |
|
|
94 |
+ |
Mode mode = none; |
95 |
+ |
|
96 |
+ |
icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON)); |
97 |
+ |
|
98 |
|
for (unsigned index = 1; index < args.size(); index++) |
99 |
|
{ |
100 |
|
if (args[index] == "-help") |
101 |
|
{ |
102 |
< |
usage(); |
102 |
> |
usage(hInstance); |
103 |
|
return 0; |
104 |
|
} |
105 |
|
else if (args[index] == "-version") |
106 |
|
{ |
107 |
< |
version(); |
107 |
> |
version(hInstance); |
108 |
|
return 0; |
109 |
|
} |
110 |
|
else if (args[index] == "-disc") |
111 |
|
{ |
112 |
< |
// |
112 |
> |
mode = disc; |
113 |
|
} |
114 |
|
else if (args[index] == "-scan") |
115 |
|
{ |
116 |
< |
// |
116 |
> |
mode = scan; |
117 |
|
} |
118 |
|
else if (args[index] == "-D") |
119 |
|
{ |
126 |
|
} |
127 |
|
} |
128 |
|
|
129 |
+ |
if (debug) |
130 |
+ |
{ |
131 |
+ |
cerr << "mode = "; |
132 |
+ |
|
133 |
+ |
switch (mode) |
134 |
+ |
{ |
135 |
+ |
case none: |
136 |
+ |
cerr << "none"; |
137 |
+ |
break; |
138 |
+ |
case disc: |
139 |
+ |
cerr << "disc"; |
140 |
+ |
break; |
141 |
+ |
case scan: |
142 |
+ |
cerr << "scan"; |
143 |
+ |
break; |
144 |
+ |
default: |
145 |
+ |
cerr << mode; |
146 |
+ |
break; |
147 |
+ |
} |
148 |
+ |
|
149 |
+ |
cerr << "\n"; |
150 |
+ |
} |
151 |
+ |
|
152 |
+ |
if (mode == none) |
153 |
+ |
{ |
154 |
+ |
// |
155 |
+ |
} |
156 |
+ |
|
157 |
+ |
if (mode == disc) |
158 |
+ |
{ |
159 |
+ |
// |
160 |
+ |
} |
161 |
+ |
else if (mode == scan) |
162 |
+ |
{ |
163 |
+ |
// |
164 |
+ |
} |
165 |
+ |
|
166 |
+ |
if (debug) |
167 |
+ |
{ |
168 |
+ |
cout << "Press enter key to exit . . ."; |
169 |
+ |
cin.get(); |
170 |
+ |
} |
171 |
+ |
|
172 |
|
return 0; |
173 |
|
} |
174 |
|
|
175 |
< |
void usage(void) |
175 |
> |
INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
176 |
|
{ |
177 |
< |
// |
177 |
> |
switch (msg) |
178 |
> |
{ |
179 |
> |
case WM_INITDIALOG: |
180 |
> |
center(dialog); |
181 |
> |
SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon)); |
182 |
> |
SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str())); |
183 |
> |
{ |
184 |
> |
ostringstream usage; |
185 |
> |
|
186 |
> |
usage << "Usage: VTBFileUtil [-help | -version | -disc | -scan]\n" |
187 |
> |
<< "\nOptions:\n" |
188 |
> |
<< " -help\t\tDisplay this information\n" |
189 |
> |
<< " -version\tDisplay version information\n" |
190 |
> |
<< " -disc\t\tStart in Disc Browse mode\n" |
191 |
> |
<< " -scan\t\tStart in Scan Utility mode\n"; |
192 |
> |
|
193 |
> |
SendMessage(GetDlgItem(dialog, IDC_USAGE_TEXT), WM_SETTEXT, 0, |
194 |
> |
LPARAM(usage.str().c_str())); |
195 |
> |
} |
196 |
> |
break; |
197 |
> |
case WM_COMMAND: |
198 |
> |
switch (LOWORD(w)) |
199 |
> |
{ |
200 |
> |
case IDOK: |
201 |
> |
case IDCANCEL: |
202 |
> |
EndDialog(dialog, w); |
203 |
> |
return TRUE; |
204 |
> |
default: |
205 |
> |
break; |
206 |
> |
} |
207 |
> |
break; |
208 |
> |
} |
209 |
> |
|
210 |
> |
return FALSE; |
211 |
|
} |
212 |
|
|
213 |
< |
void version(void) |
213 |
> |
INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
214 |
|
{ |
215 |
< |
// |
215 |
> |
switch (msg) |
216 |
> |
{ |
217 |
> |
case WM_INITDIALOG: |
218 |
> |
center(dialog); |
219 |
> |
SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon)); |
220 |
> |
SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str())); |
221 |
> |
{ |
222 |
> |
ostringstream version; |
223 |
> |
version << programName << " ( " << programVersion << " )\n\n" |
224 |
> |
<< "Copyright © 2003, Douglas Thrift.\n"; |
225 |
> |
|
226 |
> |
SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0, |
227 |
> |
LPARAM(version.str().c_str())); |
228 |
> |
} |
229 |
> |
break; |
230 |
> |
case WM_COMMAND: |
231 |
> |
switch (LOWORD(w)) |
232 |
> |
{ |
233 |
> |
case IDOK: |
234 |
> |
case IDCANCEL: |
235 |
> |
EndDialog(dialog, w); |
236 |
> |
return TRUE; |
237 |
> |
default: |
238 |
> |
break; |
239 |
> |
} |
240 |
> |
break; |
241 |
> |
} |
242 |
> |
|
243 |
> |
return FALSE; |
244 |
|
} |