2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: ScanUtility.cxx,v 1.5 2003/08/20 05:49:34 douglas Exp $ |
5 |
> |
// $Id: ScanUtility.cxx,v 1.8 2003/08/24 07:31:45 douglas Exp $ |
6 |
|
|
7 |
|
#include "ScanUtility.h" |
8 |
|
|
14 |
|
|
15 |
|
sprintf(title, "%s - Scan Utility", programName.c_str()); |
16 |
|
loadDirs(); |
17 |
+ |
|
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]); |
52 |
|
wizard[0].lParam = number; |
53 |
|
wizard[0].pszHeaderTitle = "Start"; |
54 |
|
wizard[0].pszHeaderSubTitle = "Change any settings before scanning."; |
55 |
+ |
|
56 |
+ |
// select |
57 |
+ |
wizard[1].dwSize = sizeof(wizard[1]); |
58 |
+ |
wizard[1].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE | |
59 |
+ |
PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; |
60 |
+ |
wizard[1].hInstance = gui.instance; |
61 |
+ |
wizard[1].pszTemplate = MAKEINTRESOURCE(IDD_SELECT); |
62 |
+ |
wizard[1].hIcon = gui.icon; |
63 |
+ |
wizard[1].pszTitle = title; |
64 |
+ |
wizard[1].pfnDlgProc = select; |
65 |
+ |
wizard[1].lParam = number; |
66 |
+ |
wizard[1].pszHeaderTitle = "Select"; |
67 |
+ |
wizard[1].pszHeaderSubTitle = "Choose the scanned document to save."; |
68 |
+ |
|
69 |
+ |
// enter |
70 |
+ |
wizard[2].dwSize = sizeof(wizard[2]); |
71 |
+ |
wizard[2].dwFlags = PSP_DEFAULT | PSP_USEHICON | PSP_USETITLE | |
72 |
+ |
PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; |
73 |
+ |
wizard[2].hInstance = gui.instance; |
74 |
+ |
wizard[2].pszTemplate = MAKEINTRESOURCE(IDD_ENTER); |
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 |
|
|
83 |
|
ScanUtility::~ScanUtility() |
84 |
|
{ |
85 |
+ |
DestroyMenu(popup); |
86 |
|
utilities.erase(number); |
87 |
|
saveDirs(); |
88 |
|
|
100 |
|
header.hwndParent = NULL; |
101 |
|
header.hInstance = gui.instance; |
102 |
|
header.pszIcon = MAKEINTRESOURCE(IDI_VTB_ICON); |
103 |
< |
header.nPages = 1; |
103 |
> |
header.nPages = 3; |
104 |
|
header.nStartPage = 0; |
105 |
|
header.ppsp = wizard; |
106 |
|
header.pszbmHeader = MAKEINTRESOURCE(IDB_VTB_BMP); |
132 |
|
switch (type) |
133 |
|
{ |
134 |
|
case REG_EXPAND_SZ: |
135 |
< |
scanDir = data; |
136 |
< |
scanEnv = true; |
135 |
> |
{ |
136 |
> |
char folder[MAX_PATH]; |
137 |
> |
|
138 |
> |
ExpandEnvironmentStrings(data, folder, MAX_PATH); |
139 |
> |
|
140 |
> |
scanDir = folder; |
141 |
> |
} |
142 |
|
break; |
143 |
|
case REG_SZ: |
144 |
|
scanDir = data; |
88 |
– |
scanEnv = false; |
145 |
|
break; |
146 |
|
default: |
147 |
|
setScanDir(); |
163 |
|
switch (type) |
164 |
|
{ |
165 |
|
case REG_EXPAND_SZ: |
166 |
< |
saveDir = data; |
167 |
< |
saveEnv = true; |
166 |
> |
{ |
167 |
> |
char folder[MAX_PATH]; |
168 |
> |
|
169 |
> |
ExpandEnvironmentStrings(data, folder, MAX_PATH); |
170 |
> |
|
171 |
> |
saveDir = folder; |
172 |
> |
} |
173 |
|
break; |
174 |
|
case REG_SZ: |
175 |
|
saveDir = data; |
115 |
– |
saveEnv = false; |
176 |
|
break; |
177 |
|
default: |
178 |
|
setSaveDir(); |
193 |
|
} |
194 |
|
|
195 |
|
if (debug) cerr << "scanDir = " << scanDir << "\n" |
196 |
< |
<< "scanEnv = " << scanEnv << "\n" |
137 |
< |
<< "saveDir = " << saveDir << "\n" |
138 |
< |
<< "saveEnv = " << saveEnv << "\n"; |
196 |
> |
<< "saveDir = " << saveDir << "\n"; |
197 |
|
} |
198 |
|
|
199 |
|
void ScanUtility::saveDirs(void) |
219 |
|
data[0] = '\0'; |
220 |
|
} |
221 |
|
|
222 |
< |
if (scanDir != data || type != (scanEnv ? REG_EXPAND_SZ : REG_SZ)) |
222 |
> |
if (scanDir != data || type != REG_SZ) |
223 |
|
{ |
224 |
< |
if (RegSetValueEx(key, "ScanDir", 0, scanEnv ? REG_EXPAND_SZ : |
225 |
< |
REG_SZ, LPBYTE(scanDir.c_str()), scanDir.length() + 1) != |
224 |
> |
if (RegSetValueEx(key, "ScanDir", 0, REG_SZ, |
225 |
> |
LPBYTE(scanDir.c_str()), scanDir.length() + 1) != |
226 |
|
ERROR_SUCCESS) |
227 |
|
{ |
228 |
|
error(); |
241 |
|
data[0] = '\0'; |
242 |
|
} |
243 |
|
|
244 |
< |
if (saveDir != data || type != (saveEnv ? REG_EXPAND_SZ : REG_SZ)) |
244 |
> |
if (saveDir != data || type != REG_SZ) |
245 |
|
{ |
246 |
< |
if (RegSetValueEx(key, "SaveDir", 0, saveEnv ? REG_EXPAND_SZ : |
247 |
< |
REG_SZ, LPBYTE(saveDir.c_str()), saveDir.length() + 1) != |
246 |
> |
if (RegSetValueEx(key, "SaveDir", 0, REG_SZ, |
247 |
> |
LPBYTE(saveDir.c_str()), saveDir.length() + 1) != |
248 |
|
ERROR_SUCCESS) |
249 |
|
{ |
250 |
|
error(); |
283 |
|
if (SHGetPathFromIDList(id, folder)) |
284 |
|
{ |
285 |
|
scanDir = folder; |
228 |
– |
scanEnv = false; |
286 |
|
} |
287 |
|
} |
288 |
|
|
312 |
|
} |
313 |
|
} |
314 |
|
while (scanDir == ""); |
315 |
+ |
|
316 |
+ |
if (debug) cerr << "scanDir = " << scanDir << "\n"; |
317 |
|
} |
318 |
|
|
319 |
|
void ScanUtility::setSaveDir(HWND parent) |
340 |
|
if (SHGetPathFromIDList(id, folder)) |
341 |
|
{ |
342 |
|
saveDir = folder; |
284 |
– |
saveEnv = false; |
343 |
|
} |
344 |
|
} |
345 |
|
|
369 |
|
} |
370 |
|
} |
371 |
|
while (saveDir == ""); |
372 |
+ |
|
373 |
+ |
if (debug) cerr << "saveDir = " << saveDir << "\n"; |
374 |
+ |
} |
375 |
+ |
|
376 |
+ |
void ScanUtility::populate(HWND parent) |
377 |
+ |
{ |
378 |
+ |
set<string> scans; |
379 |
+ |
|
380 |
+ |
do |
381 |
+ |
{ |
382 |
+ |
string scan = scanDir + "\\SCAN????_000." + |
383 |
+ |
IndividualClient::getExtension(); |
384 |
+ |
WIN32_FIND_DATA found; |
385 |
+ |
HANDLE finder = FindFirstFile(scan.c_str(), &found); |
386 |
+ |
|
387 |
+ |
if (finder != INVALID_HANDLE_VALUE) |
388 |
+ |
{ |
389 |
+ |
do |
390 |
+ |
{ |
391 |
+ |
scans.insert(found.cFileName); |
392 |
+ |
} |
393 |
+ |
while (FindNextFile(finder, &found)); |
394 |
+ |
|
395 |
+ |
FindClose(finder); |
396 |
+ |
} |
397 |
+ |
|
398 |
+ |
if (scans.empty()) |
399 |
+ |
{ |
400 |
+ |
if (MessageBox(parent, "No scanned documents found.", |
401 |
+ |
programName.c_str(), MB_RETRYCANCEL | MB_ICONQUESTION) == |
402 |
+ |
IDCANCEL) break; |
403 |
+ |
} |
404 |
+ |
} |
405 |
+ |
while (scans.empty()); |
406 |
+ |
|
407 |
+ |
if (scans.empty()) |
408 |
+ |
{ |
409 |
+ |
PropSheet_PressButton(GetParent(parent), PSBTN_BACK); |
410 |
+ |
} |
411 |
+ |
else |
412 |
+ |
{ |
413 |
+ |
SHFILEINFO info; |
414 |
+ |
HIMAGELIST icons = HIMAGELIST(SHGetFileInfo((*scans.begin()).c_str(), |
415 |
+ |
0, &info, sizeof(info), SHGFI_SMALLICON | SHGFI_SYSICONINDEX)); |
416 |
+ |
|
417 |
+ |
ListView_SetImageList(GetDlgItem(parent, IDC_SELECT_SCANS), icons, |
418 |
+ |
LVSIL_SMALL); |
419 |
+ |
|
420 |
+ |
if (debug) cerr << "scans = {\n"; |
421 |
+ |
|
422 |
+ |
for (set<string>::iterator itor = scans.begin(); itor != scans.end(); |
423 |
+ |
itor++) |
424 |
+ |
{ |
425 |
+ |
if (debug) cerr << " " << *itor << "\n"; |
426 |
+ |
|
427 |
+ |
char scan[MAX_PATH]; |
428 |
+ |
|
429 |
+ |
sprintf(scan, "%s", (*itor).c_str()); |
430 |
+ |
|
431 |
+ |
LVITEM item; |
432 |
+ |
|
433 |
+ |
item.mask = LVIF_IMAGE | LVIF_TEXT; |
434 |
+ |
item.iItem = 0; |
435 |
+ |
item.iSubItem = 0; |
436 |
+ |
item.pszText = scan; |
437 |
+ |
item.iImage = info.iIcon; |
438 |
+ |
|
439 |
+ |
ListView_InsertItem(GetDlgItem(parent, IDC_SELECT_SCANS), &item); |
440 |
+ |
} |
441 |
+ |
|
442 |
+ |
if (debug) cerr << "}\n"; |
443 |
+ |
|
444 |
+ |
ListView_SetItemState(GetDlgItem(parent, IDC_SELECT_SCANS), 0, |
445 |
+ |
LVIS_SELECTED, LVIS_SELECTED); |
446 |
+ |
} |
447 |
+ |
} |
448 |
+ |
|
449 |
+ |
ScanUtility* ScanUtility::which(HWND window) |
450 |
+ |
{ |
451 |
+ |
map<HWND, ScanUtility*>::iterator itor = windows.find(window); |
452 |
+ |
|
453 |
+ |
return itor->second; |
454 |
+ |
} |
455 |
+ |
|
456 |
+ |
ScanUtility* ScanUtility::which(HWND window, LPARAM l) |
457 |
+ |
{ |
458 |
+ |
LPPROPSHEETPAGE page = LPPROPSHEETPAGE(l); |
459 |
+ |
map<unsigned, ScanUtility*>::iterator itor = utilities.find(page->lParam); |
460 |
+ |
|
461 |
+ |
windows.insert(pair<HWND, ScanUtility*>(window, itor->second)); |
462 |
+ |
|
463 |
+ |
return itor->second; |
464 |
|
} |
465 |
|
|
466 |
|
int ScanUtility::browse(HWND dialog, UINT msg, LPARAM l, LPARAM d) |
475 |
|
SendMessage(dialog, BFFM_SETOKTEXT, 0, |
476 |
|
LPARAM(toWide("&Select").c_str())); |
477 |
|
SendMessage(dialog, BFFM_SETEXPANDED, FALSE, CSIDL_DRIVES); |
478 |
< |
if (HIWORD(d) ? data->scanEnv : data->saveEnv) |
479 |
< |
{ |
330 |
< |
char folder[MAX_PATH]; |
331 |
< |
|
332 |
< |
ExpandEnvironmentStrings(HIWORD(d) ? data->scanDir.c_str() : |
333 |
< |
data->saveDir.c_str(), folder, MAX_PATH); |
334 |
< |
SendMessage(dialog, BFFM_SETSELECTION, TRUE, LPARAM(folder)); |
335 |
< |
} |
336 |
< |
else |
337 |
< |
{ |
338 |
< |
SendMessage(dialog, BFFM_SETSELECTION, TRUE, LPARAM(HIWORD(d) ? |
339 |
< |
data->scanDir.c_str() : data->saveDir.c_str())); |
340 |
< |
} |
478 |
> |
SendMessage(dialog, BFFM_SETSELECTION, TRUE, LPARAM(HIWORD(d) ? |
479 |
> |
data->scanDir.c_str() : data->saveDir.c_str())); |
480 |
|
break; |
481 |
|
case BFFM_SELCHANGED: |
482 |
|
{ |
508 |
|
|
509 |
|
INT_PTR ScanUtility::start(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
510 |
|
{ |
511 |
< |
map<HWND, ScanUtility*>::iterator itor = windows.find(dialog); |
373 |
< |
ScanUtility* data = itor->second; |
511 |
> |
ScanUtility* data = which(dialog); |
512 |
|
|
513 |
|
switch (msg) |
514 |
|
{ |
515 |
|
case WM_INITDIALOG: |
516 |
|
center(GetParent(dialog)); |
517 |
+ |
SendMessage(GetParent(dialog), WM_SETICON, ICON_BIG, LPARAM(gui.icon)); |
518 |
+ |
|
519 |
+ |
data = which(dialog, l); |
520 |
+ |
|
521 |
|
{ |
522 |
< |
LPPROPSHEETPAGE page = LPPROPSHEETPAGE(l); |
523 |
< |
map<unsigned, ScanUtility*>::iterator itor = |
524 |
< |
utilities.find(page->lParam); |
522 |
> |
ostringstream instructions; |
523 |
> |
|
524 |
> |
instructions << "1. If you need instructions, you should not be ru" |
525 |
> |
<< "nning this program in Scan Utility mode.\n" |
526 |
> |
<< "2. Otherwise, go forth and scan.\n" |
527 |
> |
<< "3. Then come back and click Next.\n"; |
528 |
|
|
529 |
< |
windows.insert(pair<HWND, ScanUtility*>(dialog, itor->second)); |
529 |
> |
SetDlgItemText(dialog, IDC_START_INSTRUCTIONS, |
530 |
> |
instructions.str().c_str()); |
531 |
|
} |
532 |
|
break; |
533 |
|
case WM_NOTIFY: |
534 |
|
{ |
535 |
< |
LPNMHDR nm = (LPNMHDR) l; |
535 |
> |
LPNMHDR nm = LPNMHDR(l); |
536 |
|
|
537 |
|
switch (nm->code) |
538 |
|
{ |
547 |
|
SetDlgItemText(dialog, IDC_START_SAVE_TEXT, folder); |
548 |
|
} |
549 |
|
break; |
550 |
+ |
case PSN_WIZNEXT: |
551 |
+ |
SetCurrentDirectory(data->scanDir.c_str()); |
552 |
+ |
break; |
553 |
|
} |
554 |
|
} |
555 |
|
break; |
575 |
|
} |
576 |
|
break; |
577 |
|
} |
578 |
+ |
break; |
579 |
+ |
} |
580 |
+ |
|
581 |
+ |
return FALSE; |
582 |
+ |
} |
583 |
+ |
|
584 |
+ |
INT_PTR ScanUtility::select(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
585 |
+ |
{ |
586 |
+ |
ScanUtility* data = which(dialog); |
587 |
+ |
|
588 |
+ |
switch (msg) |
589 |
+ |
{ |
590 |
+ |
case WM_INITDIALOG: |
591 |
+ |
data = which(dialog, l); |
592 |
+ |
|
593 |
+ |
{ |
594 |
+ |
ostringstream select; |
595 |
+ |
|
596 |
+ |
select << "Select the scanned document that you need to be save."; |
597 |
+ |
|
598 |
+ |
SetDlgItemText(dialog, IDC_SELECT_TEXT, select.str().c_str()); |
599 |
+ |
} |
600 |
+ |
|
601 |
+ |
{ |
602 |
+ |
LVCOLUMN column; |
603 |
+ |
|
604 |
+ |
column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; |
605 |
+ |
column.fmt = LVCFMT_IMAGE; |
606 |
+ |
column.cx = 120; |
607 |
+ |
column.pszText = "Scanned Documents"; |
608 |
+ |
|
609 |
+ |
ListView_InsertColumn(GetDlgItem(dialog, IDC_SELECT_SCANS), 0, |
610 |
+ |
&column); |
611 |
+ |
} |
612 |
+ |
break; |
613 |
+ |
case WM_NOTIFY: |
614 |
+ |
if (w == IDC_SELECT_SCANS) |
615 |
+ |
{ |
616 |
+ |
LPNMITEMACTIVATE ni = LPNMITEMACTIVATE(l); |
617 |
+ |
|
618 |
+ |
switch (ni->hdr.code) |
619 |
+ |
{ |
620 |
+ |
case NM_DBLCLK: |
621 |
+ |
{ |
622 |
+ |
char scan[MAX_PATH]; |
623 |
+ |
|
624 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
625 |
+ |
ni->iItem, 0, scan, MAX_PATH); |
626 |
+ |
ShellExecute(dialog, NULL, scan, NULL, NULL, |
627 |
+ |
SW_SHOWDEFAULT); |
628 |
+ |
} |
629 |
+ |
break; |
630 |
+ |
} |
631 |
+ |
} |
632 |
+ |
else |
633 |
+ |
{ |
634 |
+ |
LPNMHDR nm = LPNMHDR(l); |
635 |
+ |
|
636 |
+ |
switch (nm->code) |
637 |
+ |
{ |
638 |
+ |
case PSN_SETACTIVE: |
639 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
640 |
+ |
PSWIZB_NEXT); |
641 |
+ |
data->populate(dialog); |
642 |
+ |
break; |
643 |
+ |
case PSN_WIZBACK: |
644 |
+ |
ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS)); |
645 |
+ |
data->client.setFile(""); |
646 |
+ |
break; |
647 |
+ |
case PSN_WIZNEXT: |
648 |
+ |
{ |
649 |
+ |
int index = ListView_GetNextItem(GetDlgItem(dialog, |
650 |
+ |
IDC_SELECT_SCANS), -1, LVNI_SELECTED); |
651 |
+ |
char scan[MAX_PATH]; |
652 |
+ |
|
653 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
654 |
+ |
index, 0, scan, MAX_PATH); |
655 |
+ |
|
656 |
+ |
data->scan = scan; |
657 |
+ |
} |
658 |
+ |
|
659 |
+ |
ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS)); |
660 |
+ |
|
661 |
+ |
if (debug) cerr << "scan = " << data->scan << "\n"; |
662 |
+ |
break; |
663 |
+ |
} |
664 |
+ |
} |
665 |
+ |
break; |
666 |
+ |
case WM_CONTEXTMENU: |
667 |
+ |
{ |
668 |
+ |
char scan[MAX_PATH]; |
669 |
+ |
POINT spot; |
670 |
+ |
LVHITTESTINFO test; |
671 |
+ |
|
672 |
+ |
test.pt.x = GET_X_LPARAM(l); |
673 |
+ |
test.pt.y = GET_Y_LPARAM(l); |
674 |
+ |
|
675 |
+ |
ScreenToClient(GetDlgItem(dialog, IDC_SELECT_SCANS), &test.pt); |
676 |
+ |
ListView_HitTest(GetDlgItem(dialog, IDC_SELECT_SCANS), &test); |
677 |
+ |
|
678 |
+ |
if (test.iItem != -1) |
679 |
+ |
{ |
680 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
681 |
+ |
test.iItem, 0, scan, MAX_PATH); |
682 |
+ |
|
683 |
+ |
spot.x = test.pt.x; |
684 |
+ |
spot.y = test.pt.y; |
685 |
+ |
} |
686 |
+ |
else if (GET_X_LPARAM(l) == -1 && GET_Y_LPARAM(l) == -1) |
687 |
+ |
{ |
688 |
+ |
int index = ListView_GetNextItem(GetDlgItem(dialog, |
689 |
+ |
IDC_SELECT_SCANS), -1, LVNI_SELECTED); |
690 |
+ |
RECT rect; |
691 |
+ |
|
692 |
+ |
ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS), |
693 |
+ |
index, 0, scan, MAX_PATH); |
694 |
+ |
ListView_EnsureVisible(GetDlgItem(dialog, IDC_SELECT_SCANS), |
695 |
+ |
index, FALSE); |
696 |
+ |
ListView_GetItemRect(GetDlgItem(dialog, IDC_SELECT_SCANS), |
697 |
+ |
index, &rect, LVIR_SELECTBOUNDS); |
698 |
+ |
|
699 |
+ |
spot.x = rect.left; |
700 |
+ |
spot.y = rect.top; |
701 |
+ |
} |
702 |
+ |
else |
703 |
+ |
{ |
704 |
+ |
break; |
705 |
+ |
} |
706 |
+ |
|
707 |
+ |
ClientToScreen(GetDlgItem(dialog, IDC_SELECT_SCANS), &spot); |
708 |
+ |
|
709 |
+ |
int code = TrackPopupMenuEx(data->popup, TPM_LEFTALIGN | |
710 |
+ |
TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD | TPM_RIGHTBUTTON, |
711 |
+ |
spot.x, spot.y, GetDlgItem(dialog, IDC_SELECT_SCANS), NULL); |
712 |
+ |
|
713 |
+ |
switch (code) |
714 |
+ |
{ |
715 |
+ |
case 1: |
716 |
+ |
ShellExecute(dialog, NULL, scan, NULL, NULL, SW_SHOWDEFAULT); |
717 |
+ |
break; |
718 |
+ |
case 2: |
719 |
+ |
{ |
720 |
+ |
SHELLEXECUTEINFO info; |
721 |
+ |
|
722 |
+ |
info.cbSize = sizeof(info); |
723 |
+ |
info.fMask = SEE_MASK_INVOKEIDLIST; |
724 |
+ |
info.hwnd = dialog; |
725 |
+ |
info.lpVerb = "properties"; |
726 |
+ |
info.lpFile = scan; |
727 |
+ |
info.lpParameters = NULL; |
728 |
+ |
info.lpDirectory = NULL; |
729 |
+ |
info.nShow = SW_SHOWDEFAULT; |
730 |
+ |
info.lpIDList = NULL; |
731 |
+ |
|
732 |
+ |
ShellExecuteEx(&info); |
733 |
+ |
} |
734 |
+ |
break; |
735 |
+ |
} |
736 |
+ |
} |
737 |
+ |
break; |
738 |
+ |
} |
739 |
+ |
|
740 |
+ |
return FALSE; |
741 |
+ |
} |
742 |
+ |
|
743 |
+ |
INT_PTR ScanUtility::enter(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
744 |
+ |
{ |
745 |
+ |
ScanUtility* data = which(dialog); |
746 |
+ |
|
747 |
+ |
switch (msg) |
748 |
+ |
{ |
749 |
+ |
case WM_INITDIALOG: |
750 |
+ |
data = which(dialog, l); |
751 |
+ |
{ |
752 |
+ |
ostringstream enter; |
753 |
+ |
|
754 |
+ |
enter << "Enter the client name and number."; |
755 |
+ |
|
756 |
+ |
SetDlgItemText(dialog, IDC_ENTER_TEXT, enter.str().c_str()); |
757 |
+ |
} |
758 |
+ |
break; |
759 |
+ |
case WM_NOTIFY: |
760 |
+ |
{ |
761 |
+ |
LPNMHDR nm = LPNMHDR(l); |
762 |
+ |
|
763 |
+ |
switch (nm->code) |
764 |
+ |
{ |
765 |
+ |
case PSN_SETACTIVE: |
766 |
+ |
if (data->client.getName() != "" && data->client.getNumber() != |
767 |
+ |
0) |
768 |
+ |
{ |
769 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
770 |
+ |
PSWIZB_NEXT); |
771 |
+ |
} |
772 |
+ |
else |
773 |
+ |
{ |
774 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK); |
775 |
+ |
} |
776 |
+ |
|
777 |
+ |
SetDlgItemText(dialog, IDC_ENTER_NAME, |
778 |
+ |
data->client.getName().c_str()); |
779 |
+ |
|
780 |
+ |
if (data->client.getNumber() != 0) |
781 |
+ |
{ |
782 |
+ |
SetDlgItemInt(dialog, IDC_ENTER_NUM, |
783 |
+ |
data->client.getNumber(), FALSE); |
784 |
+ |
} |
785 |
+ |
else |
786 |
+ |
{ |
787 |
+ |
SetDlgItemText(dialog, IDC_ENTER_NUM, ""); |
788 |
+ |
} |
789 |
+ |
break; |
790 |
+ |
case PSN_WIZBACK: |
791 |
+ |
break; |
792 |
+ |
case PSN_WIZNEXT: |
793 |
+ |
if (debug) |
794 |
+ |
{ |
795 |
+ |
cerr << "client = {\n" |
796 |
+ |
<< " name = " << data->client.getName() << "\n" |
797 |
+ |
<< " number = " << data->client.getNumber() << "\n" |
798 |
+ |
<< "}\n"; |
799 |
+ |
} |
800 |
+ |
break; |
801 |
+ |
} |
802 |
+ |
} |
803 |
+ |
break; |
804 |
+ |
case WM_COMMAND: |
805 |
+ |
switch (LOWORD(w)) |
806 |
+ |
{ |
807 |
+ |
case IDC_ENTER_NAME: |
808 |
+ |
{ |
809 |
+ |
char name[BUFSIZ]; |
810 |
+ |
|
811 |
+ |
GetDlgItemText(dialog, IDC_ENTER_NAME, name, BUFSIZ); |
812 |
+ |
|
813 |
+ |
if (name != data->client.getName()) |
814 |
+ |
{ |
815 |
+ |
data->client.setName(name); |
816 |
+ |
} |
817 |
+ |
} |
818 |
+ |
|
819 |
+ |
if (data->client.getName() != "" && data->client.getNumber() != 0) |
820 |
+ |
{ |
821 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
822 |
+ |
PSWIZB_NEXT); |
823 |
+ |
} |
824 |
+ |
else |
825 |
+ |
{ |
826 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK); |
827 |
+ |
} |
828 |
+ |
break; |
829 |
+ |
case IDC_ENTER_NUM: |
830 |
+ |
{ |
831 |
+ |
unsigned number = GetDlgItemInt(dialog, IDC_ENTER_NUM, NULL, |
832 |
+ |
FALSE); |
833 |
+ |
|
834 |
+ |
if (number != data->client.getNumber()) |
835 |
+ |
{ |
836 |
+ |
data->client.setNumber(number); |
837 |
+ |
} |
838 |
+ |
} |
839 |
+ |
|
840 |
+ |
if (data->client.getName() != "" && data->client.getNumber() != 0) |
841 |
+ |
{ |
842 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK | |
843 |
+ |
PSWIZB_NEXT); |
844 |
+ |
} |
845 |
+ |
else |
846 |
+ |
{ |
847 |
+ |
PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK); |
848 |
+ |
} |
849 |
+ |
break; |
850 |
+ |
} |
851 |
|
break; |
852 |
|
} |
853 |
|
|