ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/VTBFileUtil2.cxx
(Generate patch)

Comparing trunk/VTBFileUtil2/VTBFileUtil2.cxx (file contents):
Revision 256 by douglas, 2003-08-15T21:56:17-07:00 vs.
Revision 260 by douglas, 2003-08-16T02:08:35-07:00

# Line 2 | Line 2
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.5 2003/08/16 09:08:35 douglas Exp $
6  
7   #include "VTBFileUtil2.h"
8 + #include "DiscBrowse.h"
9 + #include "ScanUtility.h"
10  
11   #include <io.h>
12   #include <fcntl.h>
# Line 16 | Line 18 | string program;
18   string programName = "Vance Thrift and Biller File Utility 2";
19   string programVersion = "2.0alpha";
20  
21 + HINSTANCE instance;
22   HICON icon;
23 <
24 < enum Mode { none, disc, scan };
23 > Mode choiceMode = none;
24 > bool choiceAlways = false;
25 > UINT_PTR tips = 0;
26  
27   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l);
28   INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l);
29 + INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l);
30  
31   inline void arguments(vector<string>& args, const string& command)
32   {
# Line 49 | Line 54 | inline void arguments(vector<string>& ar
54   inline void munge(void)
55   {
56          AllocConsole();
57 <        SetConsoleTitle("Renegade Map Selector");
57 >        SetConsoleTitle(programName.c_str());
58  
59          int hin = _open_osfhandle(long(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT);
60          int hout = _open_osfhandle(long(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
# Line 72 | Line 77 | inline void munge(void)
77          cerr.sync_with_stdio();
78   }
79  
80 < inline void usage(HINSTANCE instance, HWND parent)
80 > inline void usage(HWND parent)
81   {
82          DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
83   }
84  
85 < inline void version(HINSTANCE instance, HWND parent)
85 > inline void version(HWND parent)
86   {
87          DialogBox(instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
88   }
89  
90 + inline void choice(Mode& mode, HWND parent)
91 + {
92 +        DialogBox(instance, MAKEINTRESOURCE(IDD_CHOICE), parent, choice);
93 +
94 +        mode = choiceMode;
95 + }
96 +
97   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
98          lpCmdLine, int nShowCmd)
99   {
100          vector<string> args;
101          
102 +        InitCommonControls();
103          arguments(args, GetCommandLine());
104  
105 +        instance = hInstance;
106          program = args[0];
107  
108          Mode mode = none;
# Line 99 | Line 113 | int WINAPI WinMain(HINSTANCE hInstance,
113          {
114                  if (args[index] == "-help")
115                  {
116 <                        usage(hInstance);
116 >                        usage();
117                          return 0;
118                  }
119                  else if (args[index] == "-version")
120                  {
121 <                        version(hInstance);
121 >                        version();
122                          return 0;
123                  }
124                  else if (args[index] == "-disc")
# Line 122 | Line 136 | int WINAPI WinMain(HINSTANCE hInstance,
136                                  debug = true;
137  
138                                  munge();
139 +                                cerr.setf(ios_base::boolalpha);
140                          }
141                  }
142 +                else
143 +                {
144 +                        string message = "Unknown argument: " + args[index];
145 +
146 +                        MessageBox(NULL, message.c_str(), programName.c_str(),
147 +                                MB_ICONWARNING);
148 +                }
149          }
150  
151          if (debug)
# Line 151 | Line 173 | int WINAPI WinMain(HINSTANCE hInstance,
173  
174          if (mode == none)
175          {
176 <                //
176 >                choice(mode);
177 >
178 >                if (debug)
179 >                {
180 >                        cerr << "mode = ";
181 >
182 >                        switch (mode)
183 >                        {
184 >                        case none:
185 >                                cerr << "none";
186 >                                break;
187 >                        case disc:
188 >                                cerr << "disc";
189 >                                break;
190 >                        case scan:
191 >                                cerr << "scan";
192 >                                break;
193 >                        default:
194 >                                cerr << mode;
195 >                                break;
196 >                        }
197 >
198 >                        cerr << "\n";
199 >                }
200          }
201  
202          if (mode == disc)
203          {
204 <                //
204 >                MessageBox(NULL, "Disc Browse mode", programName.c_str(),
205 >                        MB_ICONINFORMATION);
206          }
207          else if (mode == scan)
208          {
209 <                //
209 >                MessageBox(NULL, "Scan Utility mode", programName.c_str(),
210 >                        MB_ICONINFORMATION);
211          }
212  
213          if (debug)
# Line 172 | Line 219 | int WINAPI WinMain(HINSTANCE hInstance,
219          return 0;
220   }
221  
222 + void tooltip(HWND tool, const string& tip)
223 + {
224 +        HWND tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP
225 +                | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
226 +                CW_USEDEFAULT, CW_USEDEFAULT, tool, NULL, instance, NULL);
227 +        RECT rect;
228 +
229 +        SetWindowPos(tooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
230 +                SWP_NOACTIVATE);
231 +
232 +        GetClientRect(tool, &rect);
233 +
234 +        TOOLINFO toolinfo;
235 +        char* ctip = new char[tip.length()];
236 +
237 +        sprintf(ctip, "%s", tip.c_str());
238 +
239 +        if (debug) cerr << "ctip = " << ctip << "\n";
240 +
241 +        toolinfo.cbSize = sizeof(TOOLINFO);
242 +        toolinfo.uFlags = TTF_SUBCLASS;
243 +        toolinfo.hwnd = tool;
244 +        toolinfo.hinst = instance;
245 +        toolinfo.uId = tips++;
246 +        toolinfo.lpszText = ctip;
247 +        toolinfo.rect.left = rect.left;
248 +        toolinfo.rect.top = rect.top;
249 +        toolinfo.rect.right = rect.right;
250 +        toolinfo.rect.bottom = rect.bottom;
251 +
252 +        SendMessage(tooltip, TTM_ADDTOOL, 0, LPARAM(LPTOOLINFO(&toolinfo)));
253 + }
254 +
255   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
256   {
257          switch (msg)
# Line 220 | Line 300 | INT_PTR CALLBACK version(HWND dialog, UI
300                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
301                  {
302                          ostringstream version;
303 +
304                          version << programName << " ( " << programVersion << " )\n\n"
305                                  << "Copyright © 2003, Douglas Thrift.\n";
306  
# Line 235 | Line 316 | INT_PTR CALLBACK version(HWND dialog, UI
316                          EndDialog(dialog, w);
317                          return TRUE;
318                  default:
319 +                        break;
320 +                }
321 +                break;
322 +        }
323 +
324 +        return FALSE;
325 + }
326 +
327 + INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l)
328 + {
329 +        switch (msg)
330 +        {
331 +        case WM_INITDIALOG:
332 +                center(dialog);
333 +                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
334 +                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
335 +                break;
336 +        case WM_COMMAND:
337 +                switch (LOWORD(w))
338 +                {
339 +                case IDC_CHOICE_DISC:
340 +                        choiceMode = disc;
341 +                        if (debug) cerr << "choiceMode = disc\n";
342 +                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
343 +                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
344 +                        break;
345 +                case IDC_CHOICE_SCAN:
346 +                        choiceMode = scan;
347 +                        if (debug) cerr << "choiceMode = scan\n";
348 +                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
349 +                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
350 +                        break;
351 +                case IDC_CHOICE_ALWAYS:
352 +                        choiceAlways = !choiceAlways;
353 +                        if (debug) cerr << "choiceAlways = " << choiceAlways << "\n";
354 +                        break;
355 +                case IDCANCEL:
356 +                        choiceMode = none;
357 +                case IDOK:
358 +                        EndDialog(dialog, w);
359 +                        return TRUE;
360 +                default:
361                          break;
362                  }
363                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines