2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: VTBFileUtil2.cxx,v 1.3 2003/08/16 06:44:42 douglas Exp $ |
5 |
> |
// $Id: VTBFileUtil2.cxx,v 1.4 2003/08/16 08:40:55 douglas Exp $ |
6 |
|
|
7 |
|
#include "VTBFileUtil2.h" |
8 |
|
|
16 |
|
string programName = "Vance Thrift and Biller File Utility 2"; |
17 |
|
string programVersion = "2.0alpha"; |
18 |
|
|
19 |
+ |
HINSTANCE instance; |
20 |
|
HICON icon; |
21 |
|
Mode choiceMode = none; |
22 |
|
bool choiceAlways = false; |
23 |
+ |
UINT_PTR tips = 0; |
24 |
|
|
25 |
|
INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l); |
26 |
|
INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l); |
52 |
|
inline void munge(void) |
53 |
|
{ |
54 |
|
AllocConsole(); |
55 |
< |
SetConsoleTitle("Renegade Map Selector"); |
55 |
> |
SetConsoleTitle(programName.c_str()); |
56 |
|
|
57 |
|
int hin = _open_osfhandle(long(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT); |
58 |
|
int hout = _open_osfhandle(long(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT); |
75 |
|
cerr.sync_with_stdio(); |
76 |
|
} |
77 |
|
|
78 |
< |
inline void usage(HINSTANCE instance, HWND parent) |
78 |
> |
inline void usage(HWND parent) |
79 |
|
{ |
80 |
|
DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage); |
81 |
|
} |
82 |
|
|
83 |
< |
inline void version(HINSTANCE instance, HWND parent) |
83 |
> |
inline void version(HWND parent) |
84 |
|
{ |
85 |
|
DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version); |
86 |
|
} |
87 |
|
|
88 |
< |
inline void choice(Mode& mode, HINSTANCE instance, HWND parent) |
88 |
> |
inline void choice(Mode& mode, HWND parent) |
89 |
|
{ |
90 |
|
DialogBox(instance, MAKEINTRESOURCE(IDD_CHOICE), parent, choice); |
91 |
|
|
100 |
|
InitCommonControls(); |
101 |
|
arguments(args, GetCommandLine()); |
102 |
|
|
103 |
+ |
instance = hInstance; |
104 |
|
program = args[0]; |
105 |
|
|
106 |
|
Mode mode = none; |
111 |
|
{ |
112 |
|
if (args[index] == "-help") |
113 |
|
{ |
114 |
< |
usage(hInstance); |
114 |
> |
usage(); |
115 |
|
return 0; |
116 |
|
} |
117 |
|
else if (args[index] == "-version") |
118 |
|
{ |
119 |
< |
version(hInstance); |
119 |
> |
version(); |
120 |
|
return 0; |
121 |
|
} |
122 |
|
else if (args[index] == "-disc") |
171 |
|
|
172 |
|
if (mode == none) |
173 |
|
{ |
174 |
< |
choice(mode, hInstance); |
174 |
> |
choice(mode); |
175 |
|
|
176 |
|
if (debug) |
177 |
|
{ |
217 |
|
return 0; |
218 |
|
} |
219 |
|
|
220 |
+ |
void tooltip(HWND tool, const string& tip) |
221 |
+ |
{ |
222 |
+ |
HWND tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP |
223 |
+ |
| TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, |
224 |
+ |
CW_USEDEFAULT, CW_USEDEFAULT, tool, NULL, instance, NULL); |
225 |
+ |
RECT rect; |
226 |
+ |
|
227 |
+ |
SetWindowPos(tooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | |
228 |
+ |
SWP_NOACTIVATE); |
229 |
+ |
|
230 |
+ |
GetClientRect(tool, &rect); |
231 |
+ |
|
232 |
+ |
TOOLINFO toolinfo; |
233 |
+ |
char* ctip = new char[tip.length()]; |
234 |
+ |
|
235 |
+ |
sprintf(ctip, "%s", tip.c_str()); |
236 |
+ |
|
237 |
+ |
if (debug) cerr << "ctip = " << ctip << "\n"; |
238 |
+ |
|
239 |
+ |
toolinfo.cbSize = sizeof(TOOLINFO); |
240 |
+ |
toolinfo.uFlags = TTF_SUBCLASS; |
241 |
+ |
toolinfo.hwnd = tool; |
242 |
+ |
toolinfo.hinst = instance; |
243 |
+ |
toolinfo.uId = tips++; |
244 |
+ |
toolinfo.lpszText = ctip; |
245 |
+ |
toolinfo.rect.left = rect.left; |
246 |
+ |
toolinfo.rect.top = rect.top; |
247 |
+ |
toolinfo.rect.right = rect.right; |
248 |
+ |
toolinfo.rect.bottom = rect.bottom; |
249 |
+ |
|
250 |
+ |
SendMessage(tooltip, TTM_ADDTOOL, 0, LPARAM(LPTOOLINFO(&toolinfo))); |
251 |
+ |
} |
252 |
+ |
|
253 |
|
INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
254 |
|
{ |
255 |
|
switch (msg) |