ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/ScanUtility.cxx
(Generate patch)

Comparing trunk/VTBFileUtil2/ScanUtility.cxx (file contents):
Revision 281 by douglas, 2003-08-25T14:56:30-07:00 vs.
Revision 283 by douglas, 2003-08-28T21:16:30-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: ScanUtility.cxx,v 1.10 2003/08/25 21:56:30 douglas Exp $
5 > // $Id: ScanUtility.cxx,v 1.12 2003/08/29 04:16:30 douglas Exp $
6  
7   #include "ScanUtility.h"
8  
9 < ScanUtility::ScanUtility()
9 > ScanUtility::ScanUtility() : DiscBrowse()
10   {
11          number = count++;
12        utilities.insert(pair<unsigned, ScanUtility*>(number, this));
13        title = new char[programName.length() + 16];
14
15        sprintf(title, "%s - Scan Utility", programName.c_str());
16        loadDirs();
12  
13 <        popup = CreatePopupMenu();
13 >        utilities.insert(pair<unsigned, ScanUtility*>(number, this));
14  
15 <        MENUITEMINFO open, separator, properties;
15 >        title = programName + " - Scan Utility";
16  
22        open.cbSize = sizeof(open);
23        open.fMask = MIIM_ID | MIIM_STATE | MIIM_TYPE;
24        open.fType = MFT_STRING;
25        open.fState = MFS_DEFAULT;
26        open.wID = 1;
27        open.dwTypeData = "&Open";
28        open.cch = 5;
29        separator.cbSize = sizeof(open);
30        separator.fMask = MIIM_TYPE;
31        separator.fType = MFT_SEPARATOR;
32        properties.cbSize = sizeof(open);
33        properties.fMask = MIIM_ID | MIIM_TYPE;
34        properties.fType = MFT_STRING;
35        properties.wID = 2;
36        properties.dwTypeData = "P&roperties";
37        properties.cch = 11;
38
39        InsertMenuItem(popup, 0, TRUE, &open);
40        InsertMenuItem(popup, 1, TRUE, &separator);
41        InsertMenuItem(popup, 2, TRUE, &properties);
42        
17          // start
18          wizard[0].dwSize = sizeof(wizard[0]);
19 <        wizard[0].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
20 <                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
19 >        wizard[0].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
20 >                PSP_USEHEADERSUBTITLE;
21          wizard[0].hInstance = gui.instance;
22          wizard[0].pszTemplate = MAKEINTRESOURCE(IDD_START);
23 <        wizard[0].hIcon = gui.icon;
50 <        wizard[0].pszTitle = title;
23 >        wizard[0].pszTitle = title.c_str();
24          wizard[0].pfnDlgProc = start;
25          wizard[0].lParam = number;
26          wizard[0].pszHeaderTitle = "Start";
# Line 55 | Line 28 | ScanUtility::ScanUtility()
28  
29          // select
30          wizard[1].dwSize = sizeof(wizard[1]);
31 <        wizard[1].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
32 <                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
31 >        wizard[1].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
32 >                PSP_USEHEADERSUBTITLE;
33          wizard[1].hInstance = gui.instance;
34          wizard[1].pszTemplate = MAKEINTRESOURCE(IDD_SELECT);
35 <        wizard[1].hIcon = gui.icon;
63 <        wizard[1].pszTitle = title;
35 >        wizard[1].pszTitle = title.c_str();
36          wizard[1].pfnDlgProc = select;
37          wizard[1].lParam = number;
38          wizard[1].pszHeaderTitle = "Select";
# Line 68 | Line 40 | ScanUtility::ScanUtility()
40  
41          // enter
42          wizard[2].dwSize = sizeof(wizard[2]);
43 <        wizard[2].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
44 <                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
43 >        wizard[2].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
44 >                PSP_USEHEADERSUBTITLE;
45          wizard[2].hInstance = gui.instance;
46          wizard[2].pszTemplate = MAKEINTRESOURCE(IDD_ENTER);
47 <        wizard[2].hIcon = gui.icon;
76 <        wizard[2].pszTitle = title;
47 >        wizard[2].pszTitle = title.c_str();
48          wizard[2].pfnDlgProc = enter;
49          wizard[2].lParam = number;
50          wizard[2].pszHeaderTitle = "Enter";
# Line 81 | Line 52 | ScanUtility::ScanUtility()
52  
53          // confirm
54          wizard[3].dwSize = sizeof(wizard[3]);
55 <        wizard[3].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
56 <                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
55 >        wizard[3].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
56 >                PSP_USEHEADERSUBTITLE;
57          wizard[3].hInstance = gui.instance;
58          wizard[3].pszTemplate = MAKEINTRESOURCE(IDD_CONFIRM);
59 <        wizard[3].hIcon = gui.icon;
89 <        wizard[3].pszTitle = title;
59 >        wizard[3].pszTitle = title.c_str();
60          wizard[3].pfnDlgProc = confirm;
61          wizard[3].lParam = number;
62          wizard[3].pszHeaderTitle = "Confirm";
# Line 94 | Line 64 | ScanUtility::ScanUtility()
64  
65          // complete
66          wizard[4].dwSize = sizeof(wizard[3]);
67 <        wizard[4].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
68 <                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
67 >        wizard[4].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
68 >                PSP_USEHEADERSUBTITLE;
69          wizard[4].hInstance = gui.instance;
70          wizard[4].pszTemplate = MAKEINTRESOURCE(IDD_DONE);
71 <        wizard[4].hIcon = gui.icon;
102 <        wizard[4].pszTitle = title;
71 >        wizard[4].pszTitle = title.c_str();
72          wizard[4].pfnDlgProc = done;
73          wizard[4].lParam = number;
74          wizard[4].pszHeaderTitle = "Done";
# Line 108 | Line 77 | ScanUtility::ScanUtility()
77  
78   ScanUtility::~ScanUtility()
79   {
111        DestroyMenu(popup);
80          utilities.erase(number);
113        saveDirs();
114
115        delete [] title;
81   }
82  
83   void ScanUtility::run(void)
84   {
85 +        loadDirs();
86 +
87          PROPSHEETHEADER header;
88  
89          // header
# Line 132 | Line 99 | void ScanUtility::run(void)
99          header.pszbmHeader = MAKEINTRESOURCE(IDB_VTB_BMP);
100  
101          PropertySheet(&header);
102 +        saveDirs();
103   }
104  
137 unsigned ScanUtility::count = 0;
105   map<unsigned, ScanUtility*> ScanUtility::utilities;
106   map<HWND, ScanUtility*> ScanUtility::windows;
107  
# Line 321 | Line 288 | void ScanUtility::setScanDir(HWND parent
288                  if (scanDir == "")
289                  {
290                          switch (MessageBox(parent, "Scan Directory needs to be selected.",
291 <                                programName.c_str(), MB_ABORTRETRYIGNORE | MB_ICONERROR))
291 >                                title.c_str(), MB_ABORTRETRYIGNORE | MB_ICONERROR))
292                          {
293                          case IDABORT:
294                                  exit(1);
# Line 378 | Line 345 | void ScanUtility::setSaveDir(HWND parent
345                  if (saveDir == "")
346                  {
347                          switch (MessageBox(parent, "Scan Directory needs to be selected.",
348 <                                programName.c_str(), MB_ABORTRETRYIGNORE | MB_ICONERROR))
348 >                                title.c_str(), MB_ABORTRETRYIGNORE | MB_ICONERROR))
349                          {
350                          case IDABORT:
351                                  exit(1);
# Line 424 | Line 391 | void ScanUtility::populate(HWND parent)
391                  if (scans.empty())
392                  {
393                          if (MessageBox(parent, "No scanned documents found.",
394 <                                programName.c_str(), MB_RETRYCANCEL | MB_ICONQUESTION) ==
395 <                                IDCANCEL) break;
394 >                                title.c_str(), MB_RETRYCANCEL | MB_ICONQUESTION) == IDCANCEL)
395 >                                break;
396                  }
397          }
398          while (scans.empty());
# Line 567 | Line 534 | INT_PTR ScanUtility::start(HWND dialog,
534                                          PSWIZB_NEXT);
535  
536                                  {
537 <                                        char folder[44];
537 >                                        SHFILEINFO info;
538 >
539 >                                        SHGetFileInfo(data->scanDir.c_str(), 0, &info,
540 >                                                sizeof(info), SHGFI_ICONLOCATION);
541 >
542 >                                        HICON icon = ExtractAssociatedIcon(gui.instance,
543 >                                                info.szDisplayName, LPWORD(&info.iIcon));
544 >
545 >                                        SendDlgItemMessage(dialog, IDC_START_SCAN_ICON,
546 >                                                STM_SETIMAGE, IMAGE_ICON, LPARAM(icon));
547 >                                        SHGetFileInfo(data->saveDir.c_str(), 0, &info,
548 >                                                sizeof(info), SHGFI_ICONLOCATION);
549 >
550 >                                        icon = ExtractAssociatedIcon(gui.instance,
551 >                                                info.szDisplayName, LPWORD(&info.iIcon));
552 >
553 >                                        SendDlgItemMessage(dialog, IDC_START_SAVE_ICON,
554 >                                                STM_SETIMAGE, IMAGE_ICON, LPARAM(icon));
555 >                                }
556 >
557 >                                {
558 >                                        char folder[38];
559  
560 <                                        PathCompactPathEx(folder, data->scanDir.c_str(), 44, 0);
560 >                                        PathCompactPathEx(folder, data->scanDir.c_str(), 38, 0);
561                                          SetDlgItemText(dialog, IDC_START_SCAN_TEXT, folder);
562 <                                        PathCompactPathEx(folder, data->saveDir.c_str(), 44, 0);
562 >                                        PathCompactPathEx(folder, data->saveDir.c_str(), 38, 0);
563                                          SetDlgItemText(dialog, IDC_START_SAVE_TEXT, folder);
564                                  }
565                                  break;
# Line 586 | Line 574 | INT_PTR ScanUtility::start(HWND dialog,
574                  {
575                  case IDC_START_SCAN_BROWSE:
576                          data->setScanDir(dialog);
577 +
578 +                        {
579 +                                SHFILEINFO info;
580 +
581 +                                SHGetFileInfo(data->scanDir.c_str(), 0, &info, sizeof(info),
582 +                                        SHGFI_ICONLOCATION);
583 +
584 +                                HICON icon = ExtractAssociatedIcon(gui.instance,
585 +                                        info.szDisplayName, LPWORD(&info.iIcon));
586 +
587 +                                SendDlgItemMessage(dialog, IDC_START_SCAN_ICON, STM_SETIMAGE,
588 +                                        IMAGE_ICON, LPARAM(icon));
589 +                        }
590 +
591                          {
592 <                                char folder[44];
592 >                                char folder[38];
593  
594 <                                PathCompactPathEx(folder, data->scanDir.c_str(), 44, 0);
594 >                                PathCompactPathEx(folder, data->scanDir.c_str(), 38, 0);
595                                  SetDlgItemText(dialog, IDC_START_SCAN_TEXT, folder);
596                          }
597                          break;
598                  case IDC_START_SAVE_BROWSE:
599                          data->setSaveDir(dialog);
600 +
601 +                        {
602 +                                SHFILEINFO info;
603 +
604 +                                SHGetFileInfo(data->saveDir.c_str(), 0, &info, sizeof(info),
605 +                                        SHGFI_ICONLOCATION);
606 +
607 +                                HICON icon = ExtractAssociatedIcon(gui.instance,
608 +                                        info.szDisplayName, LPWORD(&info.iIcon));
609 +
610 +                                SendDlgItemMessage(dialog, IDC_START_SAVE_ICON, STM_SETIMAGE,
611 +                                        IMAGE_ICON, LPARAM(icon));
612 +                        }
613 +
614                          {
615 <                                char folder[44];
615 >                                char folder[38];
616  
617 <                                PathCompactPathEx(folder, data->saveDir.c_str(), 44, 0);
617 >                                PathCompactPathEx(folder, data->saveDir.c_str(), 38, 0);
618                                  SetDlgItemText(dialog, IDC_START_SAVE_TEXT, folder);
619                          }
620                          break;
# Line 621 | Line 637 | INT_PTR ScanUtility::select(HWND dialog,
637                  {
638                          ostringstream select;
639  
640 <                        select << "Select the scanned document that you need to be save.";
640 >                        select << "Select the scanned document that you need to save.";
641  
642                          SetDlgItemText(dialog, IDC_SELECT_TEXT, select.str().c_str());
643                  }
# Line 955 | Line 971 | INT_PTR ScanUtility::confirm(HWND dialog
971                                                  LPVOID message;
972                                                  
973                                                  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
974 <                                                        FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
975 <                                                        LPTSTR(&message), 0, NULL);
974 >                                                        FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
975 >                                                        0, LPTSTR(&message), 0, NULL);
976  
977                                                  int code = MessageBox(dialog, LPCTSTR(message),
978 <                                                        programName.c_str(), MB_RETRYCANCEL |
978 >                                                        data->title.c_str(), MB_RETRYCANCEL |
979                                                          MB_ICONEXCLAMATION);
980  
981                                                  LocalFree(message);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines