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 259 by douglas, 2003-08-16T01:40:55-07:00 vs.
Revision 291 by douglas, 2003-09-05T01:57:00-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.cxx,v 1.4 2003/08/16 08:40:55 douglas Exp $
5 > // $Id: VTBFileUtil2.cxx,v 1.13 2003/09/05 08:57:00 douglas Exp $
6  
7   #include "VTBFileUtil2.h"
8 + #include "Chooser.h"
9 + #include "DiscBrowse.h"
10 + #include "ScanUtility.h"
11  
12   #include <io.h>
13   #include <fcntl.h>
14  
12 #include "resource.h"
13
15   bool debug = false;
16   string program;
17   string programName = "Vance Thrift and Biller File Utility 2";
18 < string programVersion = "2.0alpha";
18 > string programVersion = "2.0beta";
19 > Gui gui;
20  
21 < HINSTANCE instance;
22 < 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);
27 < INT_PTR CALLBACK choice(HWND dialog, UINT msg, WPARAM w, LPARAM l);
21 > static INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l);
22 > static INT_PTR CALLBACK version(HWND dialog, UINT msg, WPARAM w, LPARAM l);
23  
24 < inline void arguments(vector<string>& args, const string& command)
24 > static inline void arguments(vector<string>& args, const string& command)
25   {
26          istringstream line(command);
27          string arg;
# Line 44 | Line 39 | inline void arguments(vector<string>& ar
39                          line.get();
40                  }
41  
42 <                args.push_back(arg);
42 >                if (arg != "")
43 >                {
44 >                        args.push_back(arg);
45 >                }
46          }
47          while (line.good());
48   }
49  
50 < inline void munge(void)
50 > static inline void munge(void)
51   {
52          AllocConsole();
53          SetConsoleTitle(programName.c_str());
# Line 75 | Line 73 | inline void munge(void)
73          cerr.sync_with_stdio();
74   }
75  
76 < inline void usage(HWND parent)
76 > void usage(HWND parent)
77   {
78 <        DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
78 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
79   }
80  
81 < inline void version(HWND parent)
81 > void version(HWND parent)
82   {
83 <        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;
83 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
84   }
85  
86   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 98 | Line 89 | int WINAPI WinMain(HINSTANCE hInstance,
89          vector<string> args;
90          
91          InitCommonControls();
92 +        CoInitialize(NULL);
93          arguments(args, GetCommandLine());
94  
103        instance = hInstance;
95          program = args[0];
96  
97          Mode mode = none;
98  
99 <        icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
99 >        gui.instance = hInstance;
100 >        gui.icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
101 >        gui.show = nShowCmd;
102  
103          for (unsigned index = 1; index < args.size(); index++)
104          {
# Line 133 | Line 126 | int WINAPI WinMain(HINSTANCE hInstance,
126                          {
127                                  debug = true;
128  
136                                munge();
129                                  cerr.setf(ios_base::boolalpha);
130                          }
131                  }
# Line 148 | Line 140 | int WINAPI WinMain(HINSTANCE hInstance,
140  
141          if (debug)
142          {
143 +                munge();
144                  cerr << "mode = ";
145  
146                  switch (mode)
# Line 169 | Line 162 | int WINAPI WinMain(HINSTANCE hInstance,
162                  cerr << "\n";
163          }
164  
165 +        License license;
166 +
167 +        license.check();
168 +
169          if (mode == none)
170          {
171 <                choice(mode);
171 >                Chooser chooser;
172 >
173 >                mode = chooser.choose();
174  
175                  if (debug)
176                  {
# Line 199 | Line 198 | int WINAPI WinMain(HINSTANCE hInstance,
198  
199          if (mode == disc)
200          {
201 <                MessageBox(NULL, "Disc Browse mode", programName.c_str(),
202 <                        MB_ICONINFORMATION);
201 >                DiscBrowse browser;
202 >
203 >                browser.run();
204          }
205          else if (mode == scan)
206          {
207 <                MessageBox(NULL, "Scan Utility mode", programName.c_str(),
208 <                        MB_ICONINFORMATION);
207 >                ScanUtility utility;
208 >
209 >                utility.run();
210          }
211  
212 +        CoUninitialize();
213 +
214          if (debug)
215          {
216                  cout << "Press enter key to exit . . .";
# Line 217 | Line 220 | int WINAPI WinMain(HINSTANCE hInstance,
220          return 0;
221   }
222  
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
223   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
224   {
225          switch (msg)
226          {
227          case WM_INITDIALOG:
228                  center(dialog);
229 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
229 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
230                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
231 +
232                  {
233                          ostringstream usage;
234  
235 <                        usage << "Usage: VTBFileUtil [-help | -version | -disc | -scan]\n"
236 <                                << "\nOptions:\n"
237 <                                << "  -help\t\tDisplay this information\n"
238 <                                << "  -version\tDisplay version information\n"
239 <                                << "  -disc\t\tStart in Disc Browse mode\n"
240 <                                << "  -scan\t\tStart in Scan Utility mode\n";
235 >                        usage << "Usage: VTBFileUtil [-help | -version | -disc | -scan]\r"
236 >                                << "\n"
237 >                                << "\r\nOptions:\r\n"
238 >                                << "  -help\t\tDisplay this information\r\n"
239 >                                << "  -version\t\tDisplay version information\r\n"
240 >                                << "  -disc\t\tStart in Disc Browse mode\r\n"
241 >                                << "  -scan\t\tStart in Scan Utility mode\r\n";
242  
243 <                        SendMessage(GetDlgItem(dialog, IDC_USAGE_TEXT), WM_SETTEXT, 0,
272 <                                LPARAM(usage.str().c_str()));
243 >                        SetDlgItemText(dialog, IDC_USAGE_TEXT, usage.str().c_str());
244                  }
245                  break;
246          case WM_COMMAND:
# Line 294 | Line 265 | INT_PTR CALLBACK version(HWND dialog, UI
265          {
266          case WM_INITDIALOG:
267                  center(dialog);
268 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
268 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
269                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
270 +                
271                  {
272                          ostringstream version;
273  
274 <                        version << programName << " ( " << programVersion << " )\n\n"
274 >                        version << programName << " (" << programVersion << ")\r\n\r\n"
275                                  << "Copyright © 2003, Douglas Thrift.\n";
276  
277 <                        SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
306 <                                LPARAM(version.str().c_str()));
277 >                        SetDlgItemText(dialog, IDC_VERSION_TEXT, version.str().c_str());
278                  }
279                  break;
280          case WM_COMMAND:
# Line 314 | Line 285 | INT_PTR CALLBACK version(HWND dialog, UI
285                          EndDialog(dialog, w);
286                          return TRUE;
287                  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:
288                          break;
289                  }
290                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines