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 262 by douglas, 2003-08-16T16:09:14-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.6 2003/08/16 23:09:14 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 102 | Line 88 | int WINAPI WinMain(HINSTANCE hInstance,
88          InitCommonControls();
89          arguments(args, GetCommandLine());
90  
105        instance = hInstance;
91          program = args[0];
92  
93          Mode mode = none;
94  
95 <        icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
95 >        gui.instance = hInstance;
96 >        gui.icon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VTB_ICON));
97 >        gui.tips = 0;
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 223 | Line 212 | void tooltip(HWND tool, const string& ti
212   {
213          HWND tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP
214                  | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,
215 <                CW_USEDEFAULT, CW_USEDEFAULT, tool, NULL, instance, NULL);
215 >                CW_USEDEFAULT, CW_USEDEFAULT, tool, NULL, gui.instance, NULL);
216          RECT rect;
217  
218          SetWindowPos(tooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE |
# Line 241 | Line 230 | void tooltip(HWND tool, const string& ti
230          toolinfo.cbSize = sizeof(TOOLINFO);
231          toolinfo.uFlags = TTF_SUBCLASS;
232          toolinfo.hwnd = tool;
233 <        toolinfo.hinst = instance;
234 <        toolinfo.uId = tips++;
233 >        toolinfo.hinst = gui.instance;
234 >        toolinfo.uId = gui.tips++;
235          toolinfo.lpszText = ctip;
236          toolinfo.rect.left = rect.left;
237          toolinfo.rect.top = rect.top;
# Line 258 | Line 247 | INT_PTR CALLBACK usage(HWND dialog, UINT
247          {
248          case WM_INITDIALOG:
249                  center(dialog);
250 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
250 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
251                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
252                  {
253                          ostringstream usage;
# Line 296 | Line 285 | INT_PTR CALLBACK version(HWND dialog, UI
285          {
286          case WM_INITDIALOG:
287                  center(dialog);
288 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(icon));
288 >                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
289                  SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
290                  {
291                          ostringstream version;
292  
293 <                        version << programName << " ( " << programVersion << " )\n\n"
293 >                        version << programName << " (" << programVersion << ")\n\n"
294                                  << "Copyright © 2003, Douglas Thrift.\n";
295  
296                          SendMessage(GetDlgItem(dialog, IDC_VERSION_TEXT), WM_SETTEXT, 0,
# Line 316 | Line 305 | INT_PTR CALLBACK version(HWND dialog, UI
305                          EndDialog(dialog, w);
306                          return TRUE;
307                  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:
308                          break;
309                  }
310                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines