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

Comparing trunk/VTBFileUtil2/DiscBrowse.cxx (file contents):
Revision 283 by douglas, 2003-08-28T21:16:30-07:00 vs.
Revision 290 by douglas, 2003-09-04T18:57:00-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: DiscBrowse.cxx,v 1.4 2003/08/29 04:16:30 douglas Exp $
5 > // $Id: DiscBrowse.cxx,v 1.8 2003/09/05 01:57:00 douglas Exp $
6  
7   #include "DiscBrowse.h"
8  
# Line 13 | Line 13 | DiscBrowse::DiscBrowse()
13          browsers.insert(pair<unsigned, DiscBrowse*>(number, this));
14  
15          title = programName + " - Disc Browse";
16
16          popup = CreatePopupMenu();
17  
18          MENUITEMINFO open, separator, properties;
# Line 39 | Line 38 | DiscBrowse::DiscBrowse()
38          InsertMenuItem(popup, 1, TRUE, &separator);
39          InsertMenuItem(popup, 2, TRUE, &properties);
40  
42        numberWidth = 56;
43        nameWidth = 224;
44        fileWidth = 152;
45        sizeWidth = 72;
46
41          // start
42          wizard[0].dwSize = sizeof(wizard[0]);
43          wizard[0].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
# Line 127 | Line 121 | void DiscBrowse::loadDir(void)
121  
122                                          ExpandEnvironmentStrings(data, folder, MAX_PATH);
123  
124 <                                        discDir = folder;
124 >                                        discDir = tail(folder);
125                                  }
126                                  break;
127                          case REG_SZ:
128 <                                discDir = data;
128 >                                discDir = tail(data);
129                                  break;
130                          default:
131                                  setDiscDir();
# Line 215 | Line 209 | void DiscBrowse::setDiscDir(HWND parent)
209                  {
210                          char folder[MAX_PATH];
211  
212 <                        if (SHGetPathFromIDList(id, folder)) discDir = folder;
219 <                }
212 >                        if (SHGetPathFromIDList(id, folder)) discDir = tail(folder);
213  
214 <                LPMALLOC destruct;
214 >                        LPMALLOC destruct;
215  
216 <                SHGetMalloc(&destruct);
217 <                destruct->Free(id);
218 <                destruct->Release();
216 >                        SHGetMalloc(&destruct);
217 >                        destruct->Free(id);
218 >                        destruct->Release();
219 >                }
220  
221                  if (discDir == "")
222                  {
# Line 248 | Line 242 | void DiscBrowse::setDiscDir(HWND parent)
242          if (debug) cerr << "discDir = " << discDir << "\n";
243   }
244  
245 + void DiscBrowse::populate(HWND parent)
246 + {
247 +        set<IndividualClient> clients;
248 +
249 +        do
250 +        {
251 +                string client = discDir + "*_*." + IndividualClient::getExtension();
252 +                WIN32_FIND_DATA found;
253 +                HANDLE finder = FindFirstFile(client.c_str(), &found);
254 +
255 +                if (finder != INVALID_HANDLE_VALUE)
256 +                {
257 +                        do
258 +                        {
259 +                                clients.insert(IndividualClient(found.cFileName));
260 +                        }
261 +                        while (FindNextFile(finder, &found));
262 +
263 +                        FindClose(finder);
264 +                }
265 +
266 +                if (clients.empty())
267 +                {
268 +                        if (MessageBox(parent, "No client documents found.",
269 +                                title.c_str(), MB_RETRYCANCEL | MB_ICONQUESTION) == IDCANCEL)
270 +                                break;
271 +                }
272 +        }
273 +        while (clients.empty());
274 +
275 +        if (!clients.empty())
276 +        {
277 +                SHFILEINFO info;
278 +                HIMAGELIST icons =
279 +                        HIMAGELIST(SHGetFileInfo((*clients.begin()).getFile().c_str(),
280 +                        0, &info, sizeof(info), SHGFI_SMALLICON | SHGFI_SYSICONINDEX));
281 +
282 +                ListView_SetImageList(GetDlgItem(parent, IDC_BROWSE_DISC), icons,
283 +                        LVSIL_SMALL);
284 +
285 +                if (debug) cerr << "clients = {\n";
286 +
287 +                for (set<IndividualClient>::iterator itor = clients.begin(); itor !=
288 +                        clients.end(); itor++)
289 +                {
290 +                        IndividualClient client = *itor;
291 +
292 +                        if (debug) cerr << "   {\n"
293 +                                << "      number = " << client.getNumber() << "\n"
294 +                                << "      name = " << client.getName() << "\n"
295 +                                << "      file = " << client.getFile() << "\n"
296 +                                << "   }\n";
297 +
298 +                        char clientFile[MAX_PATH], clientNumber[MAX_PATH],
299 +                                clientName[MAX_PATH], clientSize[MAX_PATH];
300 +                        HANDLE fileSize = CreateFile(client.getFile().c_str(),
301 +                                GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
302 +                                FILE_ATTRIBUTE_NORMAL, NULL);
303 +                        DWORD bytes = GetFileSize(fileSize, NULL);
304 +
305 +                        CloseHandle(fileSize);
306 +                        sprintf(clientFile, "%s", client.getFile().c_str());
307 +                        sprintf(clientNumber, "%u", client.getNumber());
308 +                        sprintf(clientName, "%s", client.getName().c_str());
309 +                        sprintf(clientSize, "%.2f MB", FLOAT(bytes) / FLOAT(1024 * 1024));
310 +
311 +                        LVITEM number, name, file, size;
312 +
313 +                        file.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
314 +                        file.iItem = 0;
315 +                        file.iSubItem = 0;
316 +                        file.pszText = clientFile;
317 +                        file.iImage = info.iIcon;
318 +                        file.lParam = bytes;
319 +
320 +                        int item = ListView_InsertItem(GetDlgItem(parent, IDC_BROWSE_DISC),
321 +                                &file);
322 +                        
323 +                        number.mask = LVIF_TEXT;
324 +                        number.iItem = item;
325 +                        number.iSubItem = 1;
326 +                        number.pszText = clientNumber;
327 +                        name.mask = LVIF_TEXT;
328 +                        name.iItem = item;
329 +                        name.iSubItem = 2;
330 +                        name.pszText = clientName;
331 +                        size.mask = LVIF_TEXT;
332 +                        size.iItem = item;
333 +                        size.iSubItem = 3;
334 +                        size.pszText = clientSize;
335 +                        
336 +                        ListView_SetItem(GetDlgItem(parent, IDC_BROWSE_DISC), &number);
337 +                        ListView_SetItem(GetDlgItem(parent, IDC_BROWSE_DISC), &name);
338 +                        ListView_SetItem(GetDlgItem(parent, IDC_BROWSE_DISC), &size);
339 +                }
340 +
341 +                if (debug) cerr << "}\n";
342 +
343 +                Thing thing;
344 +
345 +                sortFile = true, sortNumber = true, sortName = true, sortSize = true;
346 +                thing.index = 1;
347 +                thing.order = sortNumber;
348 +                thing.list = GetDlgItem(parent, IDC_BROWSE_DISC);
349 +                sortNumber = !sortNumber;
350 +
351 +                ListView_SortItemsEx(thing.list, sort, &thing);
352 +        }
353 + }
354 +
355   DiscBrowse* DiscBrowse::which(HWND window)
356   {
357          map<HWND, DiscBrowse*>::iterator itor = windows.find(window);
# Line 277 | Line 381 | int DiscBrowse::browse(HWND dialog, UINT
381                  SendMessage(dialog, BFFM_SETOKTEXT, 0,
382                          LPARAM(toWide("&Select").c_str()));
383                  SendMessage(dialog, BFFM_SETEXPANDED, FALSE, CSIDL_DRIVES);
384 <                SendMessage(dialog, BFFM_SETSELECTION, TRUE,
385 <                        LPARAM(data->discDir.c_str()));
384 >
385 >                if (data->discDir != "")
386 >                {
387 >                        IShellFolder* desktop;
388 >                        LPWSTR path = new WCHAR[data->discDir.length() + 1];
389 >                        LPITEMIDLIST id;
390 >
391 >                        wsprintfW(path, toWide(data->discDir).c_str());
392 >
393 >                        if (debug) cerr << "path = " << toAnsi(path) << "\n";
394 >
395 >                        SHGetDesktopFolder(&desktop);
396 >                        desktop->ParseDisplayName(dialog, NULL, path, NULL, &id, NULL);
397 >
398 >                        if (id != NULL)
399 >                        {
400 >                                SendMessage(dialog, BFFM_SETSELECTION, FALSE, LPARAM(id));
401 >
402 >                                LPMALLOC destruct;
403 >
404 >                                SHGetMalloc(&destruct);
405 >                                destruct->Free(id);
406 >                                destruct->Release();
407 >                        }
408 >
409 >                        desktop->Release();
410 >                }
411                  break;
412          case BFFM_SELCHANGED:
413                  {
414 <                        IShellFolder* object;
414 >                        SHFILEINFO info;
415  
416 <                        SHGetDesktopFolder(&object);
416 >                        SHGetFileInfo(LPCSTR(l), 0, &info, sizeof(info), SHGFI_DISPLAYNAME
417 >                                | SHGFI_PIDL);
418 >                        SendMessage(dialog, BFFM_SETSTATUSTEXT, 0,
419 >                                LPARAM(info.szDisplayName));
420  
421 <                        STRRET thing;
290 <                        char* folder;
291 <
292 <                        object->GetDisplayNameOf(LPCITEMIDLIST(l), SHGDN_FORPARSING,
293 <                                &thing);
294 <                        StrRetToStr(&thing, LPCITEMIDLIST(l), &folder);
295 <                        SendMessage(dialog, BFFM_SETSTATUSTEXT, 0, LPARAM(folder));
421 >                        char folder[MAX_PATH];
422  
423 <                        if (PathIsUNCServer(folder))
423 >                        if (!SHGetPathFromIDList(LPCITEMIDLIST(l), folder))
424                          {
425                                  SendMessage(dialog, BFFM_ENABLEOK, 0, 0);
426                          }
427 +                }
428 +                break;
429 +        }
430 +
431 +        return 0;
432 + }
433 +
434 + int DiscBrowse::sort(LPARAM first, LPARAM second, LPARAM l)
435 + {
436 +        Thing* thing = (Thing*)(l);
437 +
438 +        switch (thing->index)
439 +        {
440 +        case 0:
441 +                {
442 +                        char one[MAX_PATH], two[MAX_PATH];
443 +
444 +                        ListView_GetItemText(thing->list, first, 0, one, MAX_PATH);
445 +                        ListView_GetItemText(thing->list, second, 0, two, MAX_PATH);
446 +
447 +                        string first = one, second = two;
448 +
449 +                        if (first < second)
450 +                        {
451 +                                return thing->order ? -1 : 1;
452 +                        }
453 +                        else if (first > second)
454 +                        {
455 +                                return thing->order ? 1 : -1;
456 +                        }
457 +                }
458 +                break;
459 +        case 1:
460 +                {
461 +                        char one[MAX_PATH], two[MAX_PATH];
462 +
463 +                        ListView_GetItemText(thing->list, first, 0, one, MAX_PATH);
464 +                        ListView_GetItemText(thing->list, second, 0, two, MAX_PATH);
465 +
466 +                        IndividualClient first(one), second(two);
467 +
468 +                        if (first < second)
469 +                        {
470 +                                return thing->order ? -1 : 1;
471 +                        }
472 +                        else if (first > second)
473 +                        {
474 +                                return thing->order ? 1 : -1;
475 +                        }
476 +                }
477 +                break;
478 +        case 2:
479 +                {
480 +                        char one[MAX_PATH], two[MAX_PATH];
481  
482 <                        CoTaskMemFree(folder);
483 <                        object->Release();
482 >                        ListView_GetItemText(thing->list, first, 2, one, MAX_PATH);
483 >                        ListView_GetItemText(thing->list, second, 2, two, MAX_PATH);
484 >
485 >                        if (mcLess(one, two))
486 >                        {
487 >                                return thing->order ? -1 : 1;
488 >                        }
489 >                        else if (mcGreater(one, two))
490 >                        {
491 >                                return thing->order ? 1 : -1;
492 >                        }
493 >                }
494 >                break;
495 >        case 3:
496 >                if (first < second)
497 >                {
498 >                        return thing->order ? -1 : 1;
499 >                }
500 >                else if (first > second)
501 >                {
502 >                        return thing->order ? 1 : -1;
503                  }
504                  break;
505          }
# Line 336 | Line 535 | INT_PTR DiscBrowse::start(HWND dialog, U
535                                          SHGetFileInfo(data->discDir.c_str(), 0, &info,
536                                                  sizeof(info), SHGFI_ICONLOCATION);
537  
538 <                                        HICON icon = ExtractAssociatedIcon(gui.instance,
539 <                                                info.szDisplayName, LPWORD(&info.iIcon));
538 >                                        HICON icon = ExtractIcon(gui.instance, info.szDisplayName,
539 >                                                info.iIcon);
540  
541                                          SendDlgItemMessage(dialog, IDC_BEGIN_ICON, STM_SETIMAGE,
542                                                  IMAGE_ICON, LPARAM(icon));
543                                  }
544  
545                                  {
546 <                                        char folder[72];
546 >                                        SHFILEINFO info;
547  
548 <                                        PathCompactPathEx(folder, data->discDir.c_str(), 72, 0);
549 <                                        SetDlgItemText(dialog, IDC_BEGIN_TEXT, folder);
548 >                                        SHGetFileInfo(data->discDir.c_str(), 0, &info,
549 >                                                sizeof(info), SHGFI_DISPLAYNAME);
550 >
551 >                                        SetDlgItemText(dialog, IDC_BEGIN_TEXT, info.szDisplayName);
552                                  }
553                                  break;
554 +                        case PSN_WIZNEXT:
555 +                                SetCurrentDirectory(data->discDir.c_str());
556 +                                break;
557                          }
558                  }
559                  break;
# Line 365 | Line 569 | INT_PTR DiscBrowse::start(HWND dialog, U
569                                  SHGetFileInfo(data->discDir.c_str(), 0, &info, sizeof(info),
570                                          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_BEGIN_ICON, STM_SETIMAGE,
576                                          IMAGE_ICON, LPARAM(icon));
577                          }
578  
579                          {
580 <                                char folder[72];
580 >                                SHFILEINFO info;
581 >
582 >                                SHGetFileInfo(data->discDir.c_str(), 0, &info,
583 >                                        sizeof(info), SHGFI_DISPLAYNAME);
584  
585 <                                PathCompactPathEx(folder, data->discDir.c_str(), 72, 0);
379 <                                SetDlgItemText(dialog, IDC_BEGIN_TEXT, folder);
585 >                                SetDlgItemText(dialog, IDC_BEGIN_TEXT, info.szDisplayName);
586                          }
587                          break;
588                  }
# Line 388 | Line 594 | INT_PTR DiscBrowse::start(HWND dialog, U
594   INT_PTR DiscBrowse::browse(HWND dialog, UINT msg, WPARAM w, LPARAM l)
595   {
596          DiscBrowse* data = which(dialog);
597 +        int previous = -1;
598  
599          switch (msg)
600          {
601          case WM_INITDIALOG:
602                  data = which(dialog, l);
603  
604 +                ListView_SetExtendedListViewStyleEx(GetDlgItem(dialog,
605 +                        IDC_BROWSE_DISC), LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP |
606 +                        LVS_EX_LABELTIP, LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP |
607 +                        LVS_EX_LABELTIP);
608 +
609                  {
610 <                        LVCOLUMN number, name, file, size;
610 >                        LVCOLUMN file, number, name, size;
611  
612 +                        file.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
613 +                        file.fmt = LVCFMT_IMAGE;
614 +                        file.cx = 224;
615 +                        file.pszText = "File Name";
616                          number.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
617 <                        number.cx = data->numberWidth;
617 >                        number.cx = 56;
618                          number.pszText = "Number";
619 <                        number.iSubItem = 0;
619 >                        number.iSubItem = 1;
620                          name.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
621 <                        name.cx = data->nameWidth;
621 >                        name.cx = 152;
622                          name.pszText = "Client Name";
623 <                        name.iSubItem = 1;
408 <                        file.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
409 <                        file.fmt = LVCFMT_IMAGE;
410 <                        file.cx = data->fileWidth;
411 <                        file.pszText = "File Name";
412 <                        file.iSubItem = 2;
623 >                        name.iSubItem = 2;
624                          size.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
625 <                        size.cx = data->sizeWidth;
625 >                        size.cx = 68;
626                          size.pszText = "Size";
627                          size.iSubItem = 3;
628  
629                          ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 0,
630                                  &file);
420                        ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 0,
421                                &number);
631                          ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 1,
632 +                                &number);
633 +                        ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 2,
634                                  &name);
635                          ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 3,
636                                  &size);
637                  }
638 +
639 +                {
640 +                        int columns[4];
641 +
642 +                        columns[0] = 1;
643 +                        columns[1] = 2;
644 +                        columns[2] = 0;
645 +                        columns[3] = 3;
646 +
647 +                        ListView_SetColumnOrderArray(GetDlgItem(dialog, IDC_BROWSE_DISC),
648 +                                4, columns);
649 +                }
650                  break;
651          case WM_NOTIFY:
652                  if (w == IDC_BROWSE_DISC)
# Line 432 | Line 655 | INT_PTR DiscBrowse::browse(HWND dialog,
655  
656                          switch (ni->hdr.code)
657                          {
658 +                        case LVN_COLUMNCLICK:
659 +                                {
660 +                                        Thing thing;
661 +
662 +                                        thing.index = ni->iSubItem;
663 +
664 +                                        switch (thing.index)
665 +                                        {
666 +                                        case 0:
667 +                                                thing.order = data->sortFile;
668 +                                                data->sortFile = !data->sortFile;
669 +                                                break;
670 +                                        case 1:
671 +                                                thing.order = data->sortNumber;
672 +                                                data->sortNumber = !data->sortNumber;
673 +                                                break;
674 +                                        case 2:
675 +                                                thing.order = data->sortName;
676 +                                                data->sortName = !data->sortName;
677 +                                                break;
678 +                                        case 3:
679 +                                                thing.order = data->sortSize;
680 +                                                data->sortSize = !data->sortSize;
681 +                                                break;
682 +                                        }
683 +
684 +                                        thing.list = GetDlgItem(dialog, IDC_BROWSE_DISC);
685 +
686 +                                        if (ni->iSubItem == 3)
687 +                                        {
688 +                                                ListView_SortItems(thing.list, sort, &thing);
689 +                                        }
690 +                                        else
691 +                                        {
692 +                                                ListView_SortItemsEx(thing.list, sort, &thing);
693 +                                        }
694 +                                }
695 +                                break;
696 +                        case LVN_ITEMCHANGED:
697 +                                if (ListView_GetNextItem(GetDlgItem(dialog,     IDC_BROWSE_DISC),
698 +                                        -1, LVNI_SELECTED) != -1)
699 +                                {
700 +                                        EnableWindow(GetDlgItem(dialog, IDC_BROWSE_OPEN), TRUE);
701 +                                        EnableWindow(GetDlgItem(dialog, IDC_BROWSE_PROP), TRUE);
702 +                                }
703 +                                else
704 +                                {
705 +                                        EnableWindow(GetDlgItem(dialog, IDC_BROWSE_OPEN), FALSE);
706 +                                        EnableWindow(GetDlgItem(dialog, IDC_BROWSE_PROP), FALSE);
707 +                                }
708 +                                break;
709                          case NM_DBLCLK:
710 <                                //
710 >                                if (ni->iItem != -1)
711 >                                {
712 >                                        char scan[MAX_PATH];
713 >
714 >                                        ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
715 >                                                ni->iItem, 0, scan, MAX_PATH);
716 >                                        ShellExecute(dialog, NULL, scan, NULL, NULL,
717 >                                                SW_SHOWDEFAULT);
718 >                                }
719                                  break;
720                          }
721                  }
# Line 446 | Line 728 | INT_PTR DiscBrowse::browse(HWND dialog,
728                          case PSN_SETACTIVE:
729                                  PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
730                                          PSWIZB_FINISH);
731 +                                data->populate(dialog);
732 +
733 +                                {
734 +                                        SHFILEINFO info;
735 +
736 +                                        SHGetFileInfo(data->discDir.c_str(), 0, &info,
737 +                                                sizeof(info), SHGFI_ICONLOCATION);
738 +
739 +                                        HICON icon = ExtractIcon(gui.instance, info.szDisplayName,
740 +                                                info.iIcon);
741 +
742 +                                        SendDlgItemMessage(dialog, IDC_BROWSE_ICON, STM_SETIMAGE,
743 +                                                IMAGE_ICON, LPARAM(icon));
744 +                                }
745 +
746 +                                {
747 +                                        SHFILEINFO info;
748 +
749 +                                        SHGetFileInfo(data->discDir.c_str(), 0, &info,
750 +                                                sizeof(info), SHGFI_DISPLAYNAME);
751 +
752 +                                        SetDlgItemText(dialog, IDC_BROWSE_TEXT,
753 +                                                info.szDisplayName);
754 +                                }
755 +                                break;
756 +                        case PSN_WIZBACK:
757 +                                EnableWindow(GetDlgItem(dialog, IDC_BROWSE_OPEN), FALSE);
758 +                                EnableWindow(GetDlgItem(dialog, IDC_BROWSE_PROP), FALSE);
759 +                                ListView_DeleteAllItems(GetDlgItem(dialog, IDC_BROWSE_DISC));
760 +                                break;
761 +                        }
762 +                }
763 +                break;
764 +        case WM_COMMAND:
765 +                switch (LOWORD(w))
766 +                {
767 +                case IDC_BROWSE_REFRESH:
768 +                        EnableWindow(GetDlgItem(dialog, IDC_BROWSE_OPEN), FALSE);
769 +                        EnableWindow(GetDlgItem(dialog, IDC_BROWSE_PROP), FALSE);
770 +                        ListView_DeleteAllItems(GetDlgItem(dialog, IDC_BROWSE_DISC));
771 +                        data->populate(dialog);
772 +                        break;
773 +                case IDC_BROWSE_OPEN:
774 +                        do
775 +                        {
776 +                                char scan[MAX_PATH];
777 +                                int index = ListView_GetNextItem(GetDlgItem(dialog,
778 +                                        IDC_BROWSE_DISC), previous, LVNI_SELECTED);
779 +
780 +                                previous = index;
781 +
782 +                                if (previous == -1) continue;
783 +
784 +                                ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
785 +                                        index, 0, scan, MAX_PATH);
786 +                                ShellExecute(dialog, NULL, scan, NULL, NULL, SW_SHOWDEFAULT);
787 +                        }
788 +                        while (previous != -1);
789 +                        break;
790 +                case IDC_BROWSE_PROP:
791 +                        do
792 +                        {
793 +                                char scan[MAX_PATH];
794 +                                int index = ListView_GetNextItem(GetDlgItem(dialog,
795 +                                        IDC_BROWSE_DISC), previous, LVNI_SELECTED);
796 +
797 +                                previous = index;
798 +
799 +                                if (previous == -1) continue;
800 +
801 +                                ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
802 +                                        index, 0, scan, MAX_PATH);
803 +
804 +                                SHELLEXECUTEINFO info;
805 +
806 +                                info.cbSize = sizeof(info);
807 +                                info.fMask = SEE_MASK_INVOKEIDLIST;
808 +                                info.hwnd = dialog;
809 +                                info.lpVerb = "properties";
810 +                                info.lpFile = scan;
811 +                                info.lpParameters = NULL;
812 +                                info.lpDirectory = NULL;
813 +                                info.nShow = SW_SHOWDEFAULT;
814 +                                info.lpIDList = NULL;
815 +
816 +                                ShellExecuteEx(&info);
817 +                        }
818 +                        while (previous != -1);
819 +                        break;
820 +                }
821 +                break;
822 +        case WM_CONTEXTMENU:
823 +                if (ListView_GetNextItem(GetDlgItem(dialog, IDC_BROWSE_DISC), -1,
824 +                        LVNI_SELECTED) != -1)
825 +                {
826 + //                      char scan[MAX_PATH];
827 +                        POINT spot;
828 +                        LVHITTESTINFO test;
829 +
830 +                        test.pt.x = GET_X_LPARAM(l);
831 +                        test.pt.y = GET_Y_LPARAM(l);
832 +
833 +                        ScreenToClient(GetDlgItem(dialog, IDC_BROWSE_DISC), &test.pt);
834 +                        ListView_HitTest(GetDlgItem(dialog, IDC_BROWSE_DISC), &test);
835 +
836 +                        if (test.iItem != -1)
837 +                        {
838 + //                              ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
839 + //                                      test.iItem, 0, scan, MAX_PATH);
840 +                                
841 +                                spot.x = test.pt.x;
842 +                                spot.y = test.pt.y;
843 +                        }
844 +                        else if (GET_X_LPARAM(l) == -1 && GET_Y_LPARAM(l) == -1)
845 +                        {
846 +                                int index = ListView_GetNextItem(GetDlgItem(dialog,
847 +                                        IDC_BROWSE_DISC), -1, LVNI_SELECTED);
848 +                                RECT rect;
849 +
850 + //                              ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
851 + //                                      index, 0, scan, MAX_PATH);
852 +                                ListView_EnsureVisible(GetDlgItem(dialog, IDC_BROWSE_DISC),
853 +                                        index, FALSE);
854 +                                ListView_GetItemRect(GetDlgItem(dialog, IDC_BROWSE_DISC),
855 +                                        index, &rect, LVIR_SELECTBOUNDS);
856 +
857 +                                spot.x = rect.left;
858 +                                spot.y = rect.top;
859 +                        }
860 +
861 +                        ClientToScreen(GetDlgItem(dialog, IDC_BROWSE_DISC), &spot);
862 +
863 +                        int code = TrackPopupMenuEx(data->popup, TPM_LEFTALIGN |
864 +                                TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD | TPM_RIGHTBUTTON,
865 +                                spot.x, spot.y, GetDlgItem(dialog, IDC_BROWSE_DISC), NULL);
866 +
867 +                        switch (code)
868 +                        {
869 +                        case 1:
870 +                                do
871 +                                {
872 +                                        char scan[MAX_PATH];
873 +                                        int index = ListView_GetNextItem(GetDlgItem(dialog,
874 +                                                IDC_BROWSE_DISC), previous, LVNI_SELECTED);
875 +
876 +                                        previous = index;
877 +
878 +                                        if (previous == -1) continue;
879 +
880 +                                        ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
881 +                                                index, 0, scan, MAX_PATH);
882 +                                        ShellExecute(dialog, NULL, scan, NULL, NULL,
883 +                                                SW_SHOWDEFAULT);
884 +                                }
885 +                                while (previous != -1);
886 +                                break;
887 +                        case 2:
888 +                                do
889 +                                {
890 +                                        char scan[MAX_PATH];
891 +                                        int index = ListView_GetNextItem(GetDlgItem(dialog,
892 +                                                IDC_BROWSE_DISC), previous, LVNI_SELECTED);
893 +
894 +                                        previous = index;
895 +
896 +                                        if (previous == -1) continue;
897 +
898 +                                        ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
899 +                                                index, 0, scan, MAX_PATH);
900 +
901 +                                        SHELLEXECUTEINFO info;
902 +
903 +                                        info.cbSize = sizeof(info);
904 +                                        info.fMask = SEE_MASK_INVOKEIDLIST;
905 +                                        info.hwnd = dialog;
906 +                                        info.lpVerb = "properties";
907 +                                        info.lpFile = scan;
908 +                                        info.lpParameters = NULL;
909 +                                        info.lpDirectory = NULL;
910 +                                        info.nShow = SW_SHOWDEFAULT;
911 +                                        info.lpIDList = NULL;
912 +
913 +                                        ShellExecuteEx(&info);
914 +                                }
915 +                                while (previous != -1);
916                                  break;
917                          }
918                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines