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 259 by douglas, 2003-08-16T01:40:55-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.4 2003/08/16 08:40:55 douglas Exp $
6  
7   #include "VTBFileUtil2.h"
8  
# Line 16 | Line 16 | string program;
16   string programName = "Vance Thrift and Biller File Utility 2";
17   string programVersion = "2.0alpha";
18  
19 + HINSTANCE instance;
20   HICON icon;
21 <
22 < enum Mode { none, disc, scan };
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);
27 + INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l);
28  
29   inline void arguments(vector<string>& args, const string& command)
30   {
# Line 49 | Line 52 | inline void arguments(vector<string>& ar
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);
# Line 72 | Line 75 | inline void munge(void)
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, HWND parent)
89 + {
90 +        DialogBox(instance, MAKEINTRESOURCE(IDD_CHOICE), parent, choice);
91 +
92 +        mode = choiceMode;
93 + }
94 +
95   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
96          lpCmdLine, int nShowCmd)
97   {
98          vector<string> args;
99          
100 +        InitCommonControls();
101          arguments(args, GetCommandLine());
102  
103 +        instance = hInstance;
104          program = args[0];
105  
106          Mode mode = none;
# Line 99 | Line 111 | int WINAPI WinMain(HINSTANCE hInstance,
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")
# Line 122 | Line 134 | int WINAPI WinMain(HINSTANCE hInstance,
134                                  debug = true;
135  
136                                  munge();
137 +                                cerr.setf(ios_base::boolalpha);
138                          }
139                  }
140 +                else
141 +                {
142 +                        string message = "Unknown argument: " + args[index];
143 +
144 +                        MessageBox(NULL, message.c_str(), programName.c_str(),
145 +                                MB_ICONWARNING);
146 +                }
147          }
148  
149          if (debug)
# Line 151 | Line 171 | int WINAPI WinMain(HINSTANCE hInstance,
171  
172          if (mode == none)
173          {
174 <                //
174 >                choice(mode);
175 >
176 >                if (debug)
177 >                {
178 >                        cerr << "mode = ";
179 >
180 >                        switch (mode)
181 >                        {
182 >                        case none:
183 >                                cerr << "none";
184 >                                break;
185 >                        case disc:
186 >                                cerr << "disc";
187 >                                break;
188 >                        case scan:
189 >                                cerr << "scan";
190 >                                break;
191 >                        default:
192 >                                cerr << mode;
193 >                                break;
194 >                        }
195 >
196 >                        cerr << "\n";
197 >                }
198          }
199  
200          if (mode == disc)
201          {
202 <                //
202 >                MessageBox(NULL, "Disc Browse mode", programName.c_str(),
203 >                        MB_ICONINFORMATION);
204          }
205          else if (mode == scan)
206          {
207 <                //
207 >                MessageBox(NULL, "Scan Utility mode", programName.c_str(),
208 >                        MB_ICONINFORMATION);
209          }
210  
211          if (debug)
# Line 172 | Line 217 | int WINAPI WinMain(HINSTANCE hInstance,
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)
# Line 220 | Line 298 | INT_PTR CALLBACK version(HWND dialog, UI
298                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
299                  {
300                          ostringstream version;
301 +
302                          version << programName << " ( " << programVersion << " )\n\n"
303                                  << "Copyright © 2003, Douglas Thrift.\n";
304  
# Line 235 | Line 314 | INT_PTR CALLBACK version(HWND dialog, UI
314                          EndDialog(dialog, w);
315                          return TRUE;
316                  default:
317 +                        break;
318 +                }
319 +                break;
320 +        }
321 +
322 +        return FALSE;
323 + }
324 +
325 + INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l)
326 + {
327 +        switch (msg)
328 +        {
329 +        case WM_INITDIALOG:
330 +                center(dialog);
331 +                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
332 +                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
333 +                break;
334 +        case WM_COMMAND:
335 +                switch (LOWORD(w))
336 +                {
337 +                case IDC_CHOICE_DISC:
338 +                        choiceMode = disc;
339 +                        if (debug) cerr << "choiceMode = disc\n";
340 +                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
341 +                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
342 +                        break;
343 +                case IDC_CHOICE_SCAN:
344 +                        choiceMode = scan;
345 +                        if (debug) cerr << "choiceMode = scan\n";
346 +                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
347 +                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
348 +                        break;
349 +                case IDC_CHOICE_ALWAYS:
350 +                        choiceAlways = !choiceAlways;
351 +                        if (debug) cerr << "choiceAlways = " << choiceAlways << "\n";
352 +                        break;
353 +                case IDCANCEL:
354 +                        choiceMode = none;
355 +                case IDOK:
356 +                        EndDialog(dialog, w);
357 +                        return TRUE;
358 +                default:
359                          break;
360                  }
361                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines