2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: ScanUtility.cxx,v 1.7 2003/08/22 06:30:14 douglas Exp $ |
5 |
> |
// $Id: ScanUtility.cxx,v 1.9 2003/08/25 07:29:00 douglas Exp $ |
6 |
|
|
7 |
|
#include "ScanUtility.h" |
8 |
|
|
15 |
|
sprintf(title, "%s - Scan Utility", programName.c_str()); |
16 |
|
loadDirs(); |
17 |
|
|
18 |
< |
menu = LoadMenu(gui.instance, MAKEINTRESOURCE(IDR_SELECT)); |
19 |
< |
popup = GetSubMenu(menu, 0); |
18 |
> |
popup = CreatePopupMenu(); |
19 |
> |
|
20 |
> |
MENUITEMINFO open, separator, properties; |
21 |
> |
|
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 |
|
|
43 |
|
// start |
44 |
|
wizard[0].dwSize = sizeof(wizard[0]); |
75 |
|
wizard[2].hIcon = gui.icon; |
76 |
|
wizard[2].pszTitle = title; |
77 |
|
wizard[2].pfnDlgProc = enter; |
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() |
110 |
|
{ |
111 |
|
DestroyMenu(popup); |
63 |
– |
DestroyMenu(menu); |
112 |
|
utilities.erase(number); |
113 |
|
saveDirs(); |
114 |
|
|
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); |
472 |
|
} |
473 |
|
} |
474 |
|
|
475 |
+ |
ScanUtility* ScanUtility::which(HWND window) |
476 |
+ |
{ |
477 |
+ |
map<HWND, ScanUtility*>::iterator itor = windows.find(window); |
478 |
+ |
|
479 |
+ |
return itor->second; |
480 |
+ |
} |
481 |
+ |
|
482 |
+ |
ScanUtility* ScanUtility::which(HWND window, LPARAM l) |
483 |
+ |
{ |
484 |
+ |
LPPROPSHEETPAGE page = LPPROPSHEETPAGE(l); |
485 |
+ |
map<unsigned, ScanUtility*>::iterator itor = utilities.find(page->lParam); |
486 |
+ |
|
487 |
+ |
windows.insert(pair<HWND, ScanUtility*>(window, itor->second)); |
488 |
+ |
|
489 |
+ |
return itor->second; |
490 |
+ |
} |
491 |
+ |
|
492 |
|
int ScanUtility::browse(HWND dialog, UINT msg, LPARAM l, LPARAM d) |
493 |
|
{ |
494 |
|
map<unsigned, ScanUtility*>::iterator itor = utilities.find(LOWORD(d)); |
534 |
|
|
535 |
|
INT_PTR ScanUtility::start(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
536 |
|
{ |
537 |
< |
map<HWND, ScanUtility*>::iterator itor = windows.find(dialog); |
473 |
< |
ScanUtility* data = itor->second; |
537 |
> |
ScanUtility* data = which(dialog); |
538 |
|
|
539 |
|
switch (msg) |
540 |
|
{ |
541 |
|
case WM_INITDIALOG: |
542 |
|
center(GetParent(dialog)); |
543 |
|
SendMessage(GetParent(dialog), WM_SETICON, ICON_BIG, LPARAM(gui.icon)); |
544 |
< |
{ |
545 |
< |
LPPROPSHEETPAGE page = LPPROPSHEETPAGE(l); |
482 |
< |
map<unsigned, ScanUtility*>::iterator itor = |
483 |
< |
utilities.find(page->lParam); |
544 |
> |
|
545 |
> |
data = which(dialog, l); |
546 |
|
|
485 |
– |
windows.insert(pair<HWND, ScanUtility*>(dialog, itor->second)); |
486 |
– |
} |
547 |
|
{ |
548 |
|
ostringstream instructions; |
549 |
|
|
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 |
|
|
611 |
|
|
612 |
|
INT_PTR ScanUtility::select(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
613 |
|
{ |
614 |
< |
map<HWND, ScanUtility*>::iterator itor = windows.find(dialog); |
553 |
< |
ScanUtility* data = itor->second; |
614 |
> |
ScanUtility* data = which(dialog); |
615 |
|
|
616 |
|
switch (msg) |
617 |
|
{ |
618 |
|
case WM_INITDIALOG: |
619 |
< |
{ |
559 |
< |
LPPROPSHEETPAGE page = LPPROPSHEETPAGE(l); |
560 |
< |
map<unsigned, ScanUtility*>::iterator itor = |
561 |
< |
utilities.find(page->lParam); |
619 |
> |
data = which(dialog, l); |
620 |
|
|
563 |
– |
windows.insert(pair<HWND, ScanUtility*>(dialog, itor->second)); |
564 |
– |
} |
621 |
|
{ |
622 |
|
ostringstream select; |
623 |
|
|
625 |
|
|
626 |
|
SetDlgItemText(dialog, IDC_SELECT_TEXT, select.str().c_str()); |
627 |
|
} |
628 |
+ |
|
629 |
|
{ |
630 |
|
LVCOLUMN column; |
631 |
|
|
645 |
|
|
646 |
|
switch (ni->hdr.code) |
647 |
|
{ |
648 |
< |
case NM_RCLICK: |
648 |
> |
case NM_DBLCLK: |
649 |
|
{ |
650 |
|
char scan[MAX_PATH]; |
651 |
|
|
652 |
|
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
653 |
|
ni->iItem, 0, scan, MAX_PATH); |
654 |
+ |
ShellExecute(dialog, NULL, scan, NULL, NULL, |
655 |
+ |
SW_SHOWDEFAULT); |
656 |
+ |
} |
657 |
+ |
break; |
658 |
+ |
} |
659 |
+ |
} |
660 |
+ |
else |
661 |
+ |
{ |
662 |
+ |
LPNMHDR nm = LPNMHDR(l); |
663 |
|
|
664 |
+ |
switch (nm->code) |
665 |
+ |
{ |
666 |
+ |
case PSN_SETACTIVE: |
667 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
668 |
+ |
PSWIZB_DISABLEDFINISH | PSWIZB_NEXT); |
669 |
+ |
data->populate(dialog); |
670 |
+ |
break; |
671 |
+ |
case PSN_WIZBACK: |
672 |
+ |
ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS)); |
673 |
+ |
data->client.setFile(""); |
674 |
+ |
break; |
675 |
+ |
case PSN_WIZNEXT: |
676 |
+ |
{ |
677 |
+ |
int index = ListView_GetNextItem(GetDlgItem(dialog, |
678 |
+ |
IDC_SELECT_SCANS), -1, LVNI_SELECTED); |
679 |
+ |
char scan[MAX_PATH]; |
680 |
+ |
|
681 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
682 |
+ |
index, 0, scan, MAX_PATH); |
683 |
+ |
|
684 |
+ |
data->scan = scan; |
685 |
+ |
} |
686 |
+ |
|
687 |
+ |
ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS)); |
688 |
+ |
|
689 |
+ |
if (debug) cerr << "scan = " << data->scan << "\n"; |
690 |
+ |
break; |
691 |
+ |
} |
692 |
+ |
} |
693 |
+ |
break; |
694 |
+ |
case WM_CONTEXTMENU: |
695 |
+ |
{ |
696 |
+ |
char scan[MAX_PATH]; |
697 |
+ |
POINT spot; |
698 |
+ |
LVHITTESTINFO test; |
699 |
+ |
|
700 |
+ |
test.pt.x = GET_X_LPARAM(l); |
701 |
+ |
test.pt.y = GET_Y_LPARAM(l); |
702 |
+ |
|
703 |
+ |
ScreenToClient(GetDlgItem(dialog, IDC_SELECT_SCANS), &test.pt); |
704 |
+ |
ListView_HitTest(GetDlgItem(dialog, IDC_SELECT_SCANS), &test); |
705 |
+ |
|
706 |
+ |
if (test.iItem != -1) |
707 |
+ |
{ |
708 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
709 |
+ |
test.iItem, 0, scan, MAX_PATH); |
710 |
+ |
|
711 |
+ |
spot.x = test.pt.x; |
712 |
+ |
spot.y = test.pt.y; |
713 |
+ |
} |
714 |
+ |
else if (GET_X_LPARAM(l) == -1 && GET_Y_LPARAM(l) == -1) |
715 |
+ |
{ |
716 |
+ |
int index = ListView_GetNextItem(GetDlgItem(dialog, |
717 |
+ |
IDC_SELECT_SCANS), -1, LVNI_SELECTED); |
718 |
+ |
RECT rect; |
719 |
+ |
|
720 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
721 |
+ |
index, 0, scan, MAX_PATH); |
722 |
+ |
ListView_EnsureVisible(GetDlgItem(dialog, IDC_SELECT_SCANS), |
723 |
+ |
index, FALSE); |
724 |
+ |
ListView_GetItemRect(GetDlgItem(dialog, IDC_SELECT_SCANS), |
725 |
+ |
index, &rect, LVIR_SELECTBOUNDS); |
726 |
+ |
|
727 |
+ |
spot.x = rect.left; |
728 |
+ |
spot.y = rect.top; |
729 |
+ |
} |
730 |
+ |
else |
731 |
+ |
{ |
732 |
+ |
break; |
733 |
+ |
} |
734 |
+ |
|
735 |
+ |
ClientToScreen(GetDlgItem(dialog, IDC_SELECT_SCANS), &spot); |
736 |
+ |
|
737 |
+ |
int code = TrackPopupMenuEx(data->popup, TPM_LEFTALIGN | |
738 |
+ |
TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD | TPM_RIGHTBUTTON, |
739 |
+ |
spot.x, spot.y, GetDlgItem(dialog, IDC_SELECT_SCANS), NULL); |
740 |
+ |
|
741 |
+ |
switch (code) |
742 |
+ |
{ |
743 |
+ |
case 1: |
744 |
+ |
ShellExecute(dialog, NULL, scan, NULL, NULL, SW_SHOWDEFAULT); |
745 |
+ |
break; |
746 |
+ |
case 2: |
747 |
+ |
{ |
748 |
|
SHELLEXECUTEINFO info; |
749 |
|
|
750 |
|
info.cbSize = sizeof(info); |
760 |
|
ShellExecuteEx(&info); |
761 |
|
} |
762 |
|
break; |
763 |
< |
case NM_DBLCLK: |
763 |
> |
} |
764 |
> |
} |
765 |
> |
break; |
766 |
> |
} |
767 |
> |
|
768 |
> |
return FALSE; |
769 |
> |
} |
770 |
> |
|
771 |
> |
INT_PTR ScanUtility::enter(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
772 |
> |
{ |
773 |
> |
ScanUtility* data = which(dialog); |
774 |
> |
|
775 |
> |
switch (msg) |
776 |
> |
{ |
777 |
> |
case WM_INITDIALOG: |
778 |
> |
data = which(dialog, l); |
779 |
> |
|
780 |
> |
{ |
781 |
> |
ostringstream enter; |
782 |
> |
|
783 |
> |
enter << "Enter the client name and number."; |
784 |
> |
|
785 |
> |
SetDlgItemText(dialog, IDC_ENTER_TEXT, enter.str().c_str()); |
786 |
> |
} |
787 |
> |
break; |
788 |
> |
case WM_NOTIFY: |
789 |
> |
{ |
790 |
> |
LPNMHDR nm = LPNMHDR(l); |
791 |
> |
|
792 |
> |
switch (nm->code) |
793 |
> |
{ |
794 |
> |
case PSN_SETACTIVE: |
795 |
> |
if (data->client.getName() != "" && data->client.getNumber() != |
796 |
> |
0) |
797 |
|
{ |
798 |
< |
char scan[MAX_PATH]; |
798 |
> |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
799 |
> |
PSWIZB_DISABLEDFINISH | PSWIZB_NEXT); |
800 |
> |
} |
801 |
> |
else |
802 |
> |
{ |
803 |
> |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
804 |
> |
PSWIZB_DISABLEDFINISH); |
805 |
> |
} |
806 |
|
|
807 |
< |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
808 |
< |
ni->iItem, 0, scan, MAX_PATH); |
809 |
< |
ShellExecute(dialog, NULL, scan, NULL, NULL, |
810 |
< |
SW_SHOWDEFAULT); |
807 |
> |
SetDlgItemText(dialog, IDC_ENTER_NAME, |
808 |
> |
data->client.getName().c_str()); |
809 |
> |
|
810 |
> |
if (data->client.getNumber() != 0) |
811 |
> |
{ |
812 |
> |
SetDlgItemInt(dialog, IDC_ENTER_NUM, |
813 |
> |
data->client.getNumber(), FALSE); |
814 |
> |
} |
815 |
> |
else |
816 |
> |
{ |
817 |
> |
SetDlgItemText(dialog, IDC_ENTER_NUM, ""); |
818 |
|
} |
819 |
|
break; |
820 |
+ |
case PSN_WIZBACK: |
821 |
+ |
break; |
822 |
+ |
case PSN_WIZNEXT: |
823 |
+ |
if (debug) |
824 |
+ |
{ |
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 |
|
} |
839 |
< |
else |
839 |
> |
break; |
840 |
> |
case WM_COMMAND: |
841 |
> |
switch (LOWORD(w)) |
842 |
> |
{ |
843 |
> |
case IDC_ENTER_NAME: |
844 |
> |
{ |
845 |
> |
char name[BUFSIZ]; |
846 |
> |
|
847 |
> |
GetDlgItemText(dialog, IDC_ENTER_NAME, name, BUFSIZ); |
848 |
> |
|
849 |
> |
if (name != data->client.getName()) |
850 |
> |
{ |
851 |
> |
data->client.setName(name); |
852 |
> |
} |
853 |
> |
} |
854 |
> |
|
855 |
> |
if (data->client.getName() != "" && data->client.getNumber() != 0) |
856 |
> |
{ |
857 |
> |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
858 |
> |
PSWIZB_DISABLEDFINISH | PSWIZB_NEXT); |
859 |
> |
} |
860 |
> |
else |
861 |
> |
{ |
862 |
> |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
863 |
> |
PSWIZB_DISABLEDFINISH); |
864 |
> |
} |
865 |
> |
break; |
866 |
> |
case IDC_ENTER_NUM: |
867 |
> |
{ |
868 |
> |
unsigned number = GetDlgItemInt(dialog, IDC_ENTER_NUM, NULL, |
869 |
> |
FALSE); |
870 |
> |
|
871 |
> |
if (number != data->client.getNumber()) |
872 |
> |
{ |
873 |
> |
data->client.setNumber(number); |
874 |
> |
} |
875 |
> |
} |
876 |
> |
|
877 |
> |
if (data->client.getName() != "" && data->client.getNumber() != 0) |
878 |
> |
{ |
879 |
> |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
880 |
> |
PSWIZB_DISABLEDFINISH | PSWIZB_NEXT); |
881 |
> |
} |
882 |
> |
else |
883 |
> |
{ |
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_NEXT); |
922 |
< |
data->populate(dialog); |
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: |
637 |
– |
ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS)); |
949 |
|
break; |
950 |
|
case PSN_WIZNEXT: |
951 |
+ |
if (MoveFile(data->scan.c_str(), data->save.c_str()) == 0) |
952 |
|
{ |
953 |
< |
int index = ListView_GetNextItem(GetDlgItem(dialog, |
954 |
< |
IDC_SELECT_SCANS), -1, LVNI_SELECTED); |
955 |
< |
char scan[MAX_PATH]; |
956 |
< |
|
957 |
< |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
958 |
< |
index, 0, scan, MAX_PATH); |
959 |
< |
|
960 |
< |
data->scan = scan; |
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 |
|
} |
650 |
– |
ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS)); |
651 |
– |
if (debug) cerr << "scan = " << data->scan << "\n"; |
652 |
– |
ShellExecute(dialog, NULL, data->scan.c_str(), NULL, NULL, |
653 |
– |
SW_SHOWDEFAULT); |
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::enter(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
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 |
|
} |