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 277 by douglas, 2003-08-24T00:31:45-07:00 vs.
Revision 278 by douglas, 2003-08-25T00:29:00-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: ScanUtility.cxx,v 1.8 2003/08/24 07:31:45 douglas Exp $
5 > // $Id: ScanUtility.cxx,v 1.9 2003/08/25 07:29:00 douglas Exp $
6  
7   #include "ScanUtility.h"
8  
# Line 78 | Line 78 | ScanUtility::ScanUtility()
78          wizard[2].lParam = number;
79          wizard[2].pszHeaderTitle = "Enter";
80          wizard[2].pszHeaderSubTitle = "Input the client information.";
81 +
82 +        // confirm
83 +        wizard[3].dwSize = sizeof(wizard[3]);
84 +        wizard[3].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
85 +                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
86 +        wizard[3].hInstance = gui.instance;
87 +        wizard[3].pszTemplate = MAKEINTRESOURCE(IDD_CONFIRM);
88 +        wizard[3].hIcon = gui.icon;
89 +        wizard[3].pszTitle = title;
90 +        wizard[3].pfnDlgProc = confirm;
91 +        wizard[3].lParam = number;
92 +        wizard[3].pszHeaderTitle = "Confirm";
93 +        wizard[3].pszHeaderSubTitle = "Make sure the file information is correct.";
94 +
95 +        // complete
96 +        wizard[4].dwSize = sizeof(wizard[3]);
97 +        wizard[4].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE |
98 +                PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
99 +        wizard[4].hInstance = gui.instance;
100 +        wizard[4].pszTemplate = MAKEINTRESOURCE(IDD_DONE);
101 +        wizard[4].hIcon = gui.icon;
102 +        wizard[4].pszTitle = title;
103 +        wizard[4].pfnDlgProc = done;
104 +        wizard[4].lParam = number;
105 +        wizard[4].pszHeaderTitle = "Done";
106 +        wizard[4].pszHeaderSubTitle = "Exit or start over for another scan.";
107   }
108  
109   ScanUtility::~ScanUtility()
# Line 96 | Line 122 | void ScanUtility::run(void)
122          // header
123          header.dwSize = sizeof(header);
124          header.dwFlags = PSH_DEFAULT | PSH_HEADER | PSH_PROPSHEETPAGE |
125 <                PSH_USEICONID | PSH_WIZARD97;
125 >                PSH_USEICONID | PSH_WIZARD97 | PSH_WIZARDHASFINISH;
126          header.hwndParent = NULL;
127          header.hInstance = gui.instance;
128          header.pszIcon = MAKEINTRESOURCE(IDI_VTB_ICON);
129 <        header.nPages = 3;
129 >        header.nPages = 5;
130          header.nStartPage = 0;
131          header.ppsp = wizard;
132          header.pszbmHeader = MAKEINTRESOURCE(IDB_VTB_BMP);
# Line 537 | Line 563 | INT_PTR ScanUtility::start(HWND dialog,
563                          switch (nm->code)
564                          {
565                          case PSN_SETACTIVE:
566 <                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_NEXT);
566 >                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_FINISH |
567 >                                        PSWIZB_NEXT);
568 >
569                                  {
570                                          char folder[44];
571  
# Line 637 | Line 665 | INT_PTR ScanUtility::select(HWND dialog,
665                          {
666                          case PSN_SETACTIVE:
667                                  PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
668 <                                        PSWIZB_NEXT);
668 >                                        PSWIZB_DISABLEDFINISH | PSWIZB_NEXT);
669                                  data->populate(dialog);
670                                  break;
671                          case PSN_WIZBACK:
# Line 748 | Line 776 | INT_PTR ScanUtility::enter(HWND dialog,
776          {
777          case WM_INITDIALOG:
778                  data = which(dialog, l);
779 +
780                  {
781                          ostringstream enter;
782  
# Line 767 | Line 796 | INT_PTR ScanUtility::enter(HWND dialog,
796                                          0)
797                                  {
798                                          PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
799 <                                                PSWIZB_NEXT);
799 >                                                PSWIZB_DISABLEDFINISH | PSWIZB_NEXT);
800                                  }
801                                  else
802                                  {
803 <                                        PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK);
803 >                                        PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
804 >                                                PSWIZB_DISABLEDFINISH);
805                                  }
806  
807                                  SetDlgItemText(dialog, IDC_ENTER_NAME,
# Line 795 | Line 825 | INT_PTR ScanUtility::enter(HWND dialog,
825                                          cerr << "client = {\n"
826                                                  << "   name = " << data->client.getName() << "\n"
827                                                  << "   number = " << data->client.getNumber() << "\n"
828 +                                                << "   file = " << data->client.getFile() << "\n"
829                                                  << "}\n";
830                                  }
831 +
832 +                                data->save = data->saveDir + '\\' + data->client.getFile();
833 +
834 +                                if (debug) cerr << "save = " << data->save << "\n";
835 +                                
836                                  break;
837                          }
838                  }
# Line 819 | Line 855 | INT_PTR ScanUtility::enter(HWND dialog,
855                          if (data->client.getName() != "" && data->client.getNumber() != 0)
856                          {
857                                  PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
858 <                                        PSWIZB_NEXT);
858 >                                        PSWIZB_DISABLEDFINISH | PSWIZB_NEXT);
859                          }
860                          else
861                          {
862 <                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK);
862 >                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
863 >                                        PSWIZB_DISABLEDFINISH);
864                          }
865                          break;
866                  case IDC_ENTER_NUM:
# Line 840 | Line 877 | INT_PTR ScanUtility::enter(HWND dialog,
877                          if (data->client.getName() != "" && data->client.getNumber() != 0)
878                          {
879                                  PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
880 <                                        PSWIZB_NEXT);
880 >                                        PSWIZB_DISABLEDFINISH | PSWIZB_NEXT);
881                          }
882                          else
883                          {
884 <                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK);
884 >                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
885 >                                        PSWIZB_DISABLEDFINISH);
886                          }
887                          break;
888                  }
889                  break;
890          }
891 +
892 +        return FALSE;
893 + }
894 +
895 + INT_PTR ScanUtility::confirm(HWND dialog, UINT msg, WPARAM w, LPARAM l)
896 + {
897 +        ScanUtility* data = which(dialog);
898 +
899 +        switch (msg)
900 +        {
901 +        case WM_INITDIALOG:
902 +                data = which(dialog, l);
903 +
904 +                {
905 +                        ostringstream confirm;
906 +
907 +                        confirm << "Confirm the client file\'s name and size.";
908 +
909 +                        SetDlgItemText(dialog, IDC_CONFIRM_TEXT, confirm.str().c_str());
910 +                }
911 +                break;
912 +        case WM_NOTIFY:
913 +                {
914 +                        LPNMHDR nm = LPNMHDR(l);
915 +
916 +                        switch (nm->code)
917 +                        {
918 +                        case PSN_SETACTIVE:
919 +                                CheckDlgButton(dialog, IDC_CONFIRM_GOOD, BST_UNCHECKED);
920 +                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
921 +                                        PSWIZB_DISABLEDFINISH);
922 +                                SetDlgItemText(dialog, IDC_CONFIRM_FILE,
923 +                                        data->client.getFile().c_str());
924 +
925 +                                {
926 +                                        HANDLE scan = CreateFile(data->scan.c_str(), GENERIC_READ,
927 +                                                FILE_SHARE_READ, NULL, OPEN_EXISTING,
928 +                                                FILE_ATTRIBUTE_NORMAL, NULL);
929 +                                        DWORD bytes = GetFileSize(scan, NULL);
930 +
931 +                                        CloseHandle(scan);
932 +
933 +                                        ostringstream size;
934 +
935 +                                        size << format(bytes);
936 +
937 +                                        size.setf(ios_base::fixed, ios_base::floatfield);
938 +                                        size.precision(2);
939 +                                        
940 +                                        FLOAT megabytes = FLOAT(bytes) / FLOAT(1024 * 1024);
941 +
942 +                                        size << " bytes (" << megabytes << " MB)";
943 +
944 +                                        SetDlgItemText(dialog, IDC_CONFIRM_SIZE,
945 +                                                size.str().c_str());
946 +                                }
947 +                                break;
948 +                        case PSN_WIZBACK:
949 +                                break;
950 +                        case PSN_WIZNEXT:
951 +                                if (MoveFile(data->scan.c_str(), data->save.c_str()) == 0)
952 +                                {
953 +                                        do
954 +                                        {
955 +                                                LPVOID message;
956 +                                                
957 +                                                FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
958 +                                                        FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
959 +                                                        LPTSTR(&message), 0, NULL);
960 +
961 +                                                int code = MessageBox(dialog, LPCTSTR(message),
962 +                                                        programName.c_str(), MB_RETRYCANCEL |
963 +                                                        MB_ICONEXCLAMATION);
964 +
965 +                                                LocalFree(message);
966 +
967 +                                                if (code == IDCANCEL)
968 +                                                {
969 +                                                        PropSheet_PressButton(GetParent(dialog),
970 +                                                                PSBTN_BACK);
971 +                                                        break;
972 +                                                }
973 +                                        }
974 +                                        while (MoveFileEx(data->scan.c_str(), data->save.c_str(),
975 +                                                MOVEFILE_REPLACE_EXISTING) == 0);
976 +                                }
977 +                                break;
978 +                        }
979 +                }
980 +                break;
981 +        case WM_COMMAND:
982 +                switch (LOWORD(w))
983 +                {
984 +                case IDC_CONFIRM_GOOD:
985 +                        if (IsDlgButtonChecked(dialog, IDC_CONFIRM_GOOD) == BST_CHECKED)
986 +                        {
987 +                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
988 +                                        PSWIZB_DISABLEDFINISH | PSWIZB_NEXT);
989 +                        }
990 +                        else
991 +                        {
992 +                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
993 +                                        PSWIZB_DISABLEDFINISH);
994 +                        }
995 +                        break;
996 +                }
997 +                break;
998 +        }
999 +
1000 +        return FALSE;
1001 + }
1002 +
1003 + INT_PTR ScanUtility::done(HWND dialog, UINT msg, WPARAM w, LPARAM l)
1004 + {
1005 +        ScanUtility* data = which(dialog);
1006 +
1007 +        switch (msg)
1008 +        {
1009 +        case WM_INITDIALOG:
1010 +                data = which(dialog, l);
1011 +                break;
1012 +        case WM_NOTIFY:
1013 +                {
1014 +                        LPNMHDR nm = LPNMHDR(l);
1015 +
1016 +                        switch (nm->code)
1017 +                        {
1018 +                        case PSN_SETACTIVE:
1019 +                                PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
1020 +                                        PSWIZB_FINISH);
1021 +                                break;
1022 +                        case PSN_WIZBACK:
1023 +                                data->client.setFile("");
1024 +                                PropSheet_SetCurSelByID(GetParent(dialog), IDD_START);
1025 +                                break;
1026 +                        case PSN_WIZFINISH:
1027 +                                break;
1028 +                        }
1029 +                }
1030 +                break;
1031 +        }
1032  
1033          return FALSE;
1034   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines