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 268 by douglas, 2003-08-18T21:39:38-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.10 2003/08/19 04:39:38 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 79 | 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);
88 < }
89 <
90 < inline void choice(Mode& mode, HWND parent)
91 < {
92 <        DialogBox(instance, MAKEINTRESOURCE(IDD_CHOICE), parent, choice);
93 <
94 <        mode = choiceMode;
80 >        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_VERSION), parent, version);
81   }
82  
83   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
# Line 100 | Line 86 | int WINAPI WinMain(HINSTANCE hInstance,
86          vector<string> args;
87          
88          InitCommonControls();
89 +        CoInitialize(NULL);
90          arguments(args, GetCommandLine());
91  
105        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 135 | Line 122 | int WINAPI WinMain(HINSTANCE hInstance,
122                          {
123                                  debug = true;
124  
138                                munge();
125                                  cerr.setf(ios_base::boolalpha);
126                          }
127                  }
# Line 150 | Line 136 | int WINAPI WinMain(HINSTANCE hInstance,
136  
137          if (debug)
138          {
139 +                munge();
140                  cerr << "mode = ";
141  
142                  switch (mode)
# Line 173 | 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 201 | 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 219 | Line 212 | int WINAPI WinMain(HINSTANCE hInstance,
212          return 0;
213   }
214  
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
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 296 | Line 256 | INT_PTR CALLBACK version(HWND dialog, UI
256          {
257          case WM_INITDIALOG:
258                  center(dialog);
259 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
259 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
260                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
261                  {
262                          ostringstream version;
263  
264 <                        version << programName << " ( " << programVersion << " )\n\n"
264 >                        version << programName << " (" << programVersion << ")\n\n"
265                                  << "Copyright © 2003, Douglas Thrift.\n";
266  
267                          SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
# Line 316 | Line 276 | INT_PTR CALLBACK version(HWND dialog, UI
276                          EndDialog(dialog, w);
277                          return TRUE;
278                  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:
279                          break;
280                  }
281                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines