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 273 by douglas, 2003-08-20T23:29:24-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.11 2003/08/21 06:29:24 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";
19 <
19 < HINSTANCE instance;
20 < HICON icon;
21 < Mode choiceMode = none;
22 < bool choiceAlways = false;
23 < 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);
27 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 77 | Line 72 | inline void munge(void)
72  
73   inline void usage(HWND parent)
74   {
75 <        DialogBox(instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
75 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_USAGE), parent, usage);
76   }
77  
78   inline void version(HWND parent)
79   {
80 <        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;
80 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
81   }
82  
83   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 98 | Line 86 | int WINAPI WinMain(HINSTANCE hInstance,
86          vector<string> args;
87          
88          InitCommonControls();
89 +        CoInitialize(NULL);
90          arguments(args, GetCommandLine());
91  
103        instance = hInstance;
92          program = args[0];
93  
94          Mode mode = none;
95  
96 <        icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
96 >        gui.instance = hInstance;
97 >        gui.icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
98  
99          for (unsigned index = 1; index < args.size(); index++)
100          {
# Line 133 | Line 122 | int WINAPI WinMain(HINSTANCE hInstance,
122                          {
123                                  debug = true;
124  
136                                munge();
125                                  cerr.setf(ios_base::boolalpha);
126                          }
127                  }
# Line 148 | Line 136 | int WINAPI WinMain(HINSTANCE hInstance,
136  
137          if (debug)
138          {
139 +                munge();
140                  cerr << "mode = ";
141  
142                  switch (mode)
# Line 171 | Line 160 | int WINAPI WinMain(HINSTANCE hInstance,
160  
161          if (mode == none)
162          {
163 <                choice(mode);
163 >                Chooser chooser;
164 >
165 >                mode = chooser.choose();
166  
167                  if (debug)
168                  {
# Line 199 | Line 190 | int WINAPI WinMain(HINSTANCE hInstance,
190  
191          if (mode == disc)
192          {
193 <                MessageBox(NULL, "Disc Browse mode", programName.c_str(),
194 <                        MB_ICONINFORMATION);
193 >                DiscBrowse browser;
194 >
195 >                browser.run();
196          }
197          else if (mode == scan)
198          {
199 <                MessageBox(NULL, "Scan Utility mode", programName.c_str(),
200 <                        MB_ICONINFORMATION);
199 >                ScanUtility utility;
200 >
201 >                utility.run();
202          }
203  
204 +        CoUninitialize();
205 +
206          if (debug)
207          {
208                  cout << "Press enter key to exit . . .";
# Line 217 | Line 212 | int WINAPI WinMain(HINSTANCE hInstance,
212          return 0;
213   }
214  
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
215   INT_PTR CALLBACK usage(HWND dialog, UINT msg, WPARAM w, LPARAM l)
216   {
217          switch (msg)
218          {
219          case WM_INITDIALOG:
220                  center(dialog);
221 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
221 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
222                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
223                  {
224                          ostringstream usage;
# Line 268 | Line 230 | INT_PTR CALLBACK usage(HWND dialog, UINT
230                                  << "  -disc\t\tStart in Disc Browse mode\n"
231                                  << "  -scan\t\tStart in Scan Utility mode\n";
232  
233 <                        SendMessage(GetDlgItem(dialog, IDC_USAGE_TEXT), WM_SETTEXT, 0,
272 <                                LPARAM(usage.str().c_str()));
233 >                        SetDlgItemText(dialog, IDC_USAGE_TEXT, usage.str().c_str());
234                  }
235                  break;
236          case WM_COMMAND:
# Line 294 | Line 255 | INT_PTR CALLBACK version(HWND dialog, UI
255          {
256          case WM_INITDIALOG:
257                  center(dialog);
258 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
258 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
259                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
260                  {
261                          ostringstream version;
262  
263 <                        version << programName << " ( " << programVersion << " )\n\n"
263 >                        version << programName << " (" << programVersion << ")\n\n"
264                                  << "Copyright © 2003, Douglas Thrift.\n";
265  
266 <                        SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
306 <                                LPARAM(version.str().c_str()));
266 >                        SetDlgItemText(dialog, IDC_VERSION_TEXT, version.str().c_str());
267                  }
268                  break;
269          case WM_COMMAND:
# Line 314 | Line 274 | INT_PTR CALLBACK version(HWND dialog, UI
274                          EndDialog(dialog, w);
275                          return TRUE;
276                  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:
277                          break;
278                  }
279                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines