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 260 by douglas, 2003-08-16T02:08:35-07:00 vs.
Revision 277 by douglas, 2003-08-24T00:31:45-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.cxx,v 1.5 2003/08/16 09:08:35 douglas Exp $
5 > // $Id: VTBFileUtil2.cxx,v 1.12 2003/08/24 07:31:45 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  
14 #include "resource.h"
15
15   bool debug = false;
16   string program;
17   string programName = "Vance Thrift and Biller File Utility 2";
18   string programVersion = "2.0alpha";
19 <
21 < HINSTANCE instance;
22 < HICON icon;
23 < Mode choiceMode = none;
24 < bool choiceAlways = false;
25 < UINT_PTR tips = 0;
19 > Gui gui;
20  
21   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l);
22   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);
23  
24   inline void arguments(vector<string>& args, const string& command)
25   {
# Line 46 | 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   }
# Line 79 | Line 75 | inline void munge(void)
75  
76   inline 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)
82   {
83 <        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;
83 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
84   }
85  
86   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 100 | Line 89 | int WINAPI WinMain(HINSTANCE hInstance,
89          vector<string> args;
90          
91          InitCommonControls();
92 +        CoInitialize(NULL);
93          arguments(args, GetCommandLine());
94  
105        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 135 | Line 126 | int WINAPI WinMain(HINSTANCE hInstance,
126                          {
127                                  debug = true;
128  
138                                munge();
129                                  cerr.setf(ios_base::boolalpha);
130                          }
131                  }
# Line 150 | Line 140 | int WINAPI WinMain(HINSTANCE hInstance,
140  
141          if (debug)
142          {
143 +                munge();
144                  cerr << "mode = ";
145  
146                  switch (mode)
# Line 173 | Line 164 | int WINAPI WinMain(HINSTANCE hInstance,
164  
165          if (mode == none)
166          {
167 <                choice(mode);
167 >                Chooser chooser;
168 >
169 >                mode = chooser.choose();
170  
171                  if (debug)
172                  {
# Line 201 | Line 194 | int WINAPI WinMain(HINSTANCE hInstance,
194  
195          if (mode == disc)
196          {
197 <                MessageBox(NULL, "Disc Browse mode", programName.c_str(),
198 <                        MB_ICONINFORMATION);
197 >                DiscBrowse browser;
198 >
199 >                browser.run();
200          }
201          else if (mode == scan)
202          {
203 <                MessageBox(NULL, "Scan Utility mode", programName.c_str(),
204 <                        MB_ICONINFORMATION);
203 >                ScanUtility utility;
204 >
205 >                utility.run();
206          }
207  
208 +        CoUninitialize();
209 +
210          if (debug)
211          {
212                  cout << "Press enter key to exit . . .";
# Line 219 | Line 216 | int WINAPI WinMain(HINSTANCE hInstance,
216          return 0;
217   }
218  
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
219   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
220   {
221          switch (msg)
222          {
223          case WM_INITDIALOG:
224                  center(dialog);
225 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
225 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
226                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
227                  {
228                          ostringstream usage;
# Line 270 | Line 234 | INT_PTR CALLBACK usage(HWND dialog, UINT
234                                  << "  -disc\t\tStart in Disc Browse mode\n"
235                                  << "  -scan\t\tStart in Scan Utility mode\n";
236  
237 <                        SendMessage(GetDlgItem(dialog, IDC_USAGE_TEXT), WM_SETTEXT, 0,
274 <                                LPARAM(usage.str().c_str()));
237 >                        SetDlgItemText(dialog, IDC_USAGE_TEXT, usage.str().c_str());
238                  }
239                  break;
240          case WM_COMMAND:
# Line 296 | Line 259 | INT_PTR CALLBACK version(HWND dialog, UI
259          {
260          case WM_INITDIALOG:
261                  center(dialog);
262 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
262 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
263                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
264                  {
265                          ostringstream version;
266  
267 <                        version << programName << " ( " << programVersion << " )\n\n"
267 >                        version << programName << " (" << programVersion << ")\n\n"
268                                  << "Copyright © 2003, Douglas Thrift.\n";
269  
270 <                        SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
308 <                                LPARAM(version.str().c_str()));
270 >                        SetDlgItemText(dialog, IDC_VERSION_TEXT, version.str().c_str());
271                  }
272                  break;
273          case WM_COMMAND:
# Line 316 | Line 278 | INT_PTR CALLBACK version(HWND dialog, UI
278                          EndDialog(dialog, w);
279                          return TRUE;
280                  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:
281                          break;
282                  }
283                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines