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

Comparing trunk/VTBFileUtil2/ScanUtility.cxx (file contents):
Revision 283 by douglas, 2003-08-28T21:16:30-07:00 vs.
Revision 295 by douglas, 2003-09-11T21:26:54-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: ScanUtility.cxx,v 1.12 2003/08/29 04:16:30 douglas Exp $
5 > // $Id: ScanUtility.cxx,v 1.18 2003/09/12 04:26:54 douglas Exp $
6  
7   #include "ScanUtility.h"
8  
# Line 130 | Line 130 | void ScanUtility::loadDirs(void)
130  
131                                          ExpandEnvironmentStrings(data, folder, MAX_PATH);
132  
133 <                                        scanDir = folder;
133 >                                        scanDir = tail(folder);
134                                  }
135                                  break;
136                          case REG_SZ:
137 <                                scanDir = data;
137 >                                scanDir = tail(data);
138                                  break;
139                          default:
140                                  setScanDir();
# Line 161 | Line 161 | void ScanUtility::loadDirs(void)
161  
162                                          ExpandEnvironmentStrings(data, folder, MAX_PATH);
163  
164 <                                        saveDir = folder;
164 >                                        saveDir = tail(folder);
165                                  }
166                                  break;
167                          case REG_SZ:
168 <                                saveDir = data;
168 >                                saveDir = tail(data);
169                                  break;
170                          default:
171                                  setSaveDir();
# Line 193 | Line 193 | void ScanUtility::saveDirs(void)
193   {
194          HKEY key;
195  
196 <        if (RegCreateKeyEx(HKEY_CURRENT_USER,
196 >        if (LONG code = RegCreateKeyEx(HKEY_CURRENT_USER,
197                  "Software\\DouglasThrift\\VTBFileUtil2", 0, NULL,
198                  REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &key,
199                  NULL) == ERROR_SUCCESS)
# Line 218 | Line 218 | void ScanUtility::saveDirs(void)
218                                  LPBYTE(scanDir.c_str()), scanDir.length() + 1) !=
219                                  ERROR_SUCCESS)
220                          {
221 <                                error();
221 >                                error(NULL, code);
222                          }
223                  }
224  
# Line 240 | Line 240 | void ScanUtility::saveDirs(void)
240                                  LPBYTE(saveDir.c_str()), saveDir.length() + 1) !=
241                                  ERROR_SUCCESS)
242                          {
243 <                                error();
243 >                                error(NULL, code);
244                          }
245                  }
246  
# Line 248 | Line 248 | void ScanUtility::saveDirs(void)
248          }
249          else
250          {
251 <                error();
251 >                error(NULL, code);
252          }
253   }
254  
255   void ScanUtility::setScanDir(HWND parent)
256   {
257 +        char buffer[MAX_PATH];
258 +
259 +        SHGetFolderPath(parent, CSIDL_FLAG_CREATE | CSIDL_DESKTOPDIRECTORY, NULL,
260 +                0, buffer);
261 +
262          BROWSEINFO info;
263  
264          info.hwndOwner = parent;
# Line 273 | Line 278 | void ScanUtility::setScanDir(HWND parent
278                  {
279                          char folder[MAX_PATH];
280  
281 <                        if (SHGetPathFromIDList(id, folder))
277 <                        {
278 <                                scanDir = folder;
279 <                        }
281 >                        if (SHGetPathFromIDList(id, folder)) scanDir = tail(folder);
282                  }
283  
284                  LPMALLOC destruct;
# Line 311 | Line 313 | void ScanUtility::setScanDir(HWND parent
313  
314   void ScanUtility::setSaveDir(HWND parent)
315   {
316 +        char buffer[MAX_PATH];
317 +
318 +        SHGetFolderPath(parent, CSIDL_FLAG_CREATE | CSIDL_DESKTOPDIRECTORY, NULL,
319 +                0, buffer);
320 +
321          BROWSEINFO info;
322  
323          info.hwndOwner = parent;
# Line 330 | Line 337 | void ScanUtility::setSaveDir(HWND parent
337                  {
338                          char folder[MAX_PATH];
339  
340 <                        if (SHGetPathFromIDList(id, folder))
334 <                        {
335 <                                saveDir = folder;
336 <                        }
340 >                        if (SHGetPathFromIDList(id, folder)) saveDir = tail(folder);
341                  }
342  
343                  LPMALLOC destruct;
# Line 372 | Line 376 | void ScanUtility::populate(HWND parent)
376  
377          do
378          {
379 <                string scan = scanDir + "\\SCAN????_000." +
379 >                string scan = scanDir + "SCAN????_000." +
380                          IndividualClient::getExtension();
381                  WIN32_FIND_DATA found;
382                  HANDLE finder = FindFirstFile(scan.c_str(), &found);
# Line 419 | Line 423 | void ScanUtility::populate(HWND parent)
423  
424                          char scan[MAX_PATH];
425  
426 <                        sprintf(scan, "%s", (*itor).c_str());
426 >                        StringCchPrintf(scan, MAX_PATH, "%s", (*itor).c_str());
427  
428                          LVITEM item;
429  
# Line 468 | Line 472 | int ScanUtility::browse(HWND dialog, UIN
472                  SendMessage(dialog, BFFM_SETOKTEXT, 0,
473                          LPARAM(toWide("&Select").c_str()));
474                  SendMessage(dialog, BFFM_SETEXPANDED, FALSE, CSIDL_DRIVES);
475 <                SendMessage(dialog, BFFM_SETSELECTION, TRUE, LPARAM(HIWORD(d) ?
476 <                        data->scanDir.c_str() : data->saveDir.c_str()));
475 >
476 >                if ((HIWORD(d) ? data->scanDir : data->saveDir) != "")
477 >                {
478 >                        IShellFolder* desktop;
479 >                        LPWSTR path = new WCHAR[(HIWORD(d) ? data->scanDir.length() :
480 >                                data->saveDir.length()) + 1];
481 >                        LPITEMIDLIST id;
482 >
483 >                        StringCchPrintfW(path, (HIWORD(d) ? data->scanDir.length() :
484 >                                data->saveDir.length()) + 1, toWide(HIWORD(d) ? data->scanDir :
485 >                                data->saveDir).c_str());
486 >
487 >                        if (debug) cerr << "path = " << toAnsi(path) << "\n";
488 >
489 >                        SHGetDesktopFolder(&desktop);
490 >                        desktop->ParseDisplayName(dialog, NULL, path, NULL, &id, NULL);
491 >
492 >                        if (id != NULL)
493 >                        {
494 >                                SendMessage(dialog, BFFM_SETSELECTION, FALSE, LPARAM(id));
495 >
496 >                                LPMALLOC destruct;
497 >
498 >                                SHGetMalloc(&destruct);
499 >                                destruct->Free(id);
500 >                                destruct->Release();
501 >                        }
502 >
503 >                        desktop->Release();
504 >                }
505                  break;
506          case BFFM_SELCHANGED:
507                  {
508 <                        IShellFolder* object;
477 <
478 <                        SHGetDesktopFolder(&object);
508 >                        SHFILEINFO info;
509  
510 <                        STRRET thing;
511 <                        char* folder;
510 >                        SHGetFileInfo(LPCSTR(l), 0, &info, sizeof(info), SHGFI_DISPLAYNAME
511 >                                | SHGFI_PIDL);
512 >                        SendMessage(dialog, BFFM_SETSTATUSTEXT, 0,
513 >                                LPARAM(info.szDisplayName));
514  
515 <                        object->GetDisplayNameOf(LPCITEMIDLIST(l), SHGDN_FORPARSING,
484 <                                &thing);
485 <                        StrRetToStr(&thing, LPCITEMIDLIST(l), &folder);
486 <                        SendMessage(dialog, BFFM_SETSTATUSTEXT, 0, LPARAM(folder));
515 >                        char folder[MAX_PATH];
516  
517 <                        if (PathIsUNCServer(folder))
517 >                        if (!SHGetPathFromIDList(LPCITEMIDLIST(l), folder))
518                          {
519                                  SendMessage(dialog, BFFM_ENABLEOK, 0, 0);
520                          }
521 <
522 <                        CoTaskMemFree(folder);
523 <                        object->Release();
521 >                        else
522 >                        {
523 >                                SendMessage(dialog, BFFM_SETSTATUSTEXT, 0, LPARAM(folder));
524 >                        }
525                  }
526                  break;
527          }
# Line 539 | Line 569 | INT_PTR ScanUtility::start(HWND dialog,
569                                          SHGetFileInfo(data->scanDir.c_str(), 0, &info,
570                                                  sizeof(info), SHGFI_ICONLOCATION);
571  
572 <                                        HICON icon = ExtractAssociatedIcon(gui.instance,
573 <                                                info.szDisplayName, LPWORD(&info.iIcon));
572 >                                        HICON icon = ExtractIcon(gui.instance, info.szDisplayName,
573 >                                                info.iIcon);
574  
575                                          SendDlgItemMessage(dialog, IDC_START_SCAN_ICON,
576                                                  STM_SETIMAGE, IMAGE_ICON, LPARAM(icon));
577                                          SHGetFileInfo(data->saveDir.c_str(), 0, &info,
578                                                  sizeof(info), SHGFI_ICONLOCATION);
579  
580 <                                        icon = ExtractAssociatedIcon(gui.instance,
581 <                                                info.szDisplayName, LPWORD(&info.iIcon));
580 >                                        icon = ExtractIcon(gui.instance, info.szDisplayName,
581 >                                                info.iIcon);
582  
583                                          SendDlgItemMessage(dialog, IDC_START_SAVE_ICON,
584                                                  STM_SETIMAGE, IMAGE_ICON, LPARAM(icon));
# Line 557 | Line 587 | INT_PTR ScanUtility::start(HWND dialog,
587                                  {
588                                          char folder[38];
589  
590 <                                        PathCompactPathEx(folder, data->scanDir.c_str(), 38, 0);
590 >                                        PathCompactPathEx(folder, data->scanDir.substr(0,
591 >                                                data->scanDir.length() - 1).c_str(), 38, 0);
592                                          SetDlgItemText(dialog, IDC_START_SCAN_TEXT, folder);
593 <                                        PathCompactPathEx(folder, data->saveDir.c_str(), 38, 0);
593 >                                        PathCompactPathEx(folder, data->saveDir.substr(0,
594 >                                                data->saveDir.length() - 1).c_str(), 38, 0);
595                                          SetDlgItemText(dialog, IDC_START_SAVE_TEXT, folder);
596                                  }
597                                  break;
# Line 581 | Line 613 | INT_PTR ScanUtility::start(HWND dialog,
613                                  SHGetFileInfo(data->scanDir.c_str(), 0, &info, sizeof(info),
614                                          SHGFI_ICONLOCATION);
615  
616 <                                HICON icon = ExtractAssociatedIcon(gui.instance,
617 <                                        info.szDisplayName, LPWORD(&info.iIcon));
616 >                                HICON icon = ExtractIcon(gui.instance, info.szDisplayName,
617 >                                        info.iIcon);
618  
619                                  SendDlgItemMessage(dialog, IDC_START_SCAN_ICON, STM_SETIMAGE,
620                                          IMAGE_ICON, LPARAM(icon));
# Line 591 | Line 623 | INT_PTR ScanUtility::start(HWND dialog,
623                          {
624                                  char folder[38];
625  
626 <                                PathCompactPathEx(folder, data->scanDir.c_str(), 38, 0);
626 >                                PathCompactPathEx(folder, data->scanDir.substr(0,
627 >                                        data->scanDir.length() - 1).c_str(), 38, 0);
628                                  SetDlgItemText(dialog, IDC_START_SCAN_TEXT, folder);
629                          }
630                          break;
# Line 604 | Line 637 | INT_PTR ScanUtility::start(HWND dialog,
637                                  SHGetFileInfo(data->saveDir.c_str(), 0, &info, sizeof(info),
638                                          SHGFI_ICONLOCATION);
639  
640 <                                HICON icon = ExtractAssociatedIcon(gui.instance,
641 <                                        info.szDisplayName, LPWORD(&info.iIcon));
640 >                                HICON icon = ExtractIcon(gui.instance, info.szDisplayName,
641 >                                        info.iIcon);
642  
643                                  SendDlgItemMessage(dialog, IDC_START_SAVE_ICON, STM_SETIMAGE,
644                                          IMAGE_ICON, LPARAM(icon));
# Line 614 | Line 647 | INT_PTR ScanUtility::start(HWND dialog,
647                          {
648                                  char folder[38];
649  
650 <                                PathCompactPathEx(folder, data->saveDir.c_str(), 38, 0);
650 >                                PathCompactPathEx(folder, data->saveDir.substr(0,
651 >                                        data->saveDir.length() - 1).c_str(), 38, 0);
652                                  SetDlgItemText(dialog, IDC_START_SAVE_TEXT, folder);
653                          }
654                          break;
# Line 662 | Line 696 | INT_PTR ScanUtility::select(HWND dialog,
696                          switch (ni->hdr.code)
697                          {
698                          case NM_DBLCLK:
699 +                                if (ni->iItem != -1)
700                                  {
701                                          char scan[MAX_PATH];
702  
# Line 694 | Line 729 | INT_PTR ScanUtility::select(HWND dialog,
729                                                  IDC_SELECT_SCANS), -1, LVNI_SELECTED);
730                                          char scan[MAX_PATH];
731  
732 <                                        ListView_GetItemText(GetDlgItem(dialog, IDC_SELECT_SCANS),
733 <                                                index, 0, scan, MAX_PATH);
732 >                                        if (index != -1)
733 >                                        {
734 >                                                ListView_GetItemText(GetDlgItem(dialog,
735 >                                                        IDC_SELECT_SCANS), index, 0, scan, MAX_PATH);
736 >                                        }
737 >                                        else
738 >                                        {
739 >                                                ListView_GetItemText(GetDlgItem(dialog,
740 >                                                        IDC_SELECT_SCANS), 0, 0, scan, MAX_PATH);
741 >                                        }
742  
743                                          data->scan = scan;
744                                  }
745  
703                                ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS));
704
746                                  if (debug) cerr << "scan = " << data->scan << "\n";
747 +
748 +                                ListView_DeleteAllItems(GetDlgItem(dialog, IDC_SELECT_SCANS));
749                                  break;
750                          }
751                  }
752                  break;
753          case WM_CONTEXTMENU:
754 +                if (ListView_GetNextItem(GetDlgItem(dialog, IDC_SELECT_SCANS), -1,
755 +                        LVNI_SELECTED) != -1)
756                  {
757                          char scan[MAX_PATH];
758                          POINT spot;
# Line 743 | Line 788 | INT_PTR ScanUtility::select(HWND dialog,
788                                  spot.x = rect.left;
789                                  spot.y = rect.top;
790                          }
746                        else
747                        {
748                                break;
749                        }
791  
792                          ClientToScreen(GetDlgItem(dialog, IDC_SELECT_SCANS), &spot);
793  
# Line 845 | Line 886 | INT_PTR ScanUtility::enter(HWND dialog,
886                                                  << "}\n";
887                                  }
888  
889 <                                data->save = data->saveDir + '\\' + data->client.getFile();
889 >                                data->save = data->saveDir + data->client.getFile();
890  
891                                  if (debug) cerr << "save = " << data->save << "\n";
892                                  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines