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 290 by douglas, 2003-09-04T18:57:00-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: DiscBrowse.cxx,v 1.8 2003/09/05 01:57:00 douglas Exp $
5 > // $Id: DiscBrowse.cxx,v 1.12 2003/09/12 04:26:54 douglas Exp $
6  
7   #include "DiscBrowse.h"
8  
# Line 151 | Line 151 | void DiscBrowse::saveDir(void)
151   {
152          HKEY key;
153  
154 <        if (RegCreateKeyEx(HKEY_CURRENT_USER,
154 >        if (LONG code = RegCreateKeyEx(HKEY_CURRENT_USER,
155                  "Software\\DouglasThrift\\VTBFileUtil2", 0, NULL,
156                  REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &key,
157                  NULL) == ERROR_SUCCESS)
# Line 172 | Line 172 | void DiscBrowse::saveDir(void)
172  
173                  if (discDir != data || type != REG_SZ)
174                  {
175 <                        if (RegSetValueEx(key, "DiscDir", 0, REG_SZ,
175 >                        if (code = RegSetValueEx(key, "DiscDir", 0, REG_SZ,
176                                  LPBYTE(discDir.c_str()), discDir.length() + 1) !=
177                                  ERROR_SUCCESS)
178                          {
179 <                                error();
179 >                                error(NULL, code);
180                          }
181                  }
182  
# Line 184 | Line 184 | void DiscBrowse::saveDir(void)
184          }
185          else
186          {
187 <                error();
187 >                error(NULL, code);
188          }
189   }
190  
191   void DiscBrowse::setDiscDir(HWND parent)
192   {
193 +        char buffer[MAX_PATH];
194 +
195 +        SHGetFolderPath(parent, CSIDL_FLAG_CREATE | CSIDL_DESKTOPDIRECTORY, NULL,
196 +                0, buffer);
197 +
198          BROWSEINFO info;
199  
200          info.hwndOwner = parent;
# Line 272 | Line 277 | void DiscBrowse::populate(HWND parent)
277          }
278          while (clients.empty());
279  
280 <        if (!clients.empty())
280 >        if (clients.empty())
281 >        {
282 >                PropSheet_PressButton(GetParent(parent), PSBTN_BACK);
283 >        }
284 >        else
285          {
286                  SHFILEINFO info;
287                  HIMAGELIST icons =
# Line 303 | Line 312 | void DiscBrowse::populate(HWND parent)
312                          DWORD bytes = GetFileSize(fileSize, NULL);
313  
314                          CloseHandle(fileSize);
315 <                        sprintf(clientFile, "%s", client.getFile().c_str());
316 <                        sprintf(clientNumber, "%u", client.getNumber());
317 <                        sprintf(clientName, "%s", client.getName().c_str());
318 <                        sprintf(clientSize, "%.2f MB", FLOAT(bytes) / FLOAT(1024 * 1024));
315 >                        StringCchPrintf(clientFile, MAX_PATH, "%s",
316 >                                client.getFile().c_str());
317 >                        StringCchPrintf(clientNumber, MAX_PATH, "%u", client.getNumber());
318 >                        StringCchPrintf(clientName, MAX_PATH, "%s",
319 >                                client.getName().c_str());
320 >                        StringCchPrintf(clientSize, MAX_PATH, "%.2f MB", FLOAT(bytes) /
321 >                                FLOAT(1024 * 1024));
322  
323                          LVITEM number, name, file, size;
324  
# Line 388 | Line 400 | int DiscBrowse::browse(HWND dialog, UINT
400                          LPWSTR path = new WCHAR[data->discDir.length() + 1];
401                          LPITEMIDLIST id;
402  
403 <                        wsprintfW(path, toWide(data->discDir).c_str());
403 >                        StringCchPrintfW(path, data->discDir.length() + 1, L"%s",
404 >                                toWide(data->discDir).c_str());
405  
406                          if (debug) cerr << "path = " << toAnsi(path) << "\n";
407  
# Line 769 | Line 782 | INT_PTR DiscBrowse::browse(HWND dialog,
782                          EnableWindow(GetDlgItem(dialog, IDC_BROWSE_PROP), FALSE);
783                          ListView_DeleteAllItems(GetDlgItem(dialog, IDC_BROWSE_DISC));
784                          data->populate(dialog);
785 +
786 +                        {
787 +                                SHFILEINFO info;
788 +
789 +                                SHGetFileInfo(data->discDir.c_str(), 0, &info, sizeof(info),
790 +                                        SHGFI_ICONLOCATION);
791 +
792 +                                HICON icon = ExtractIcon(gui.instance, info.szDisplayName,
793 +                                        info.iIcon);
794 +
795 +                                SendDlgItemMessage(dialog, IDC_BROWSE_ICON, STM_SETIMAGE,
796 +                                        IMAGE_ICON, LPARAM(icon));
797 +                        }
798 +
799 +                        {
800 +                                SHFILEINFO info;
801 +
802 +                                SHGetFileInfo(data->discDir.c_str(), 0, &info, sizeof(info),
803 +                                        SHGFI_DISPLAYNAME);
804 +
805 +                                SetDlgItemText(dialog, IDC_BROWSE_TEXT, info.szDisplayName);
806 +                        }
807                          break;
808                  case IDC_BROWSE_OPEN:
809                          do
# Line 823 | Line 858 | INT_PTR DiscBrowse::browse(HWND dialog,
858                  if (ListView_GetNextItem(GetDlgItem(dialog, IDC_BROWSE_DISC), -1,
859                          LVNI_SELECTED) != -1)
860                  {
826 //                      char scan[MAX_PATH];
861                          POINT spot;
862                          LVHITTESTINFO test;
863  
# Line 835 | Line 869 | INT_PTR DiscBrowse::browse(HWND dialog,
869  
870                          if (test.iItem != -1)
871                          {
838 //                              ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
839 //                                      test.iItem, 0, scan, MAX_PATH);
840                                
872                                  spot.x = test.pt.x;
873                                  spot.y = test.pt.y;
874                          }
# Line 847 | Line 878 | INT_PTR DiscBrowse::browse(HWND dialog,
878                                          IDC_BROWSE_DISC), -1, LVNI_SELECTED);
879                                  RECT rect;
880  
850 //                              ListView_GetItemText(GetDlgItem(dialog, IDC_BROWSE_DISC),
851 //                                      index, 0, scan, MAX_PATH);
881                                  ListView_EnsureVisible(GetDlgItem(dialog, IDC_BROWSE_DISC),
882                                          index, FALSE);
883                                  ListView_GetItemRect(GetDlgItem(dialog, IDC_BROWSE_DISC),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines