diff --git a/reactos/subsys/system/explorer/shell/entries.cpp b/reactos/subsys/system/explorer/shell/entries.cpp index 53ba186b8eb..4637a6d288b 100644 --- a/reactos/subsys/system/explorer/shell/entries.cpp +++ b/reactos/subsys/system/explorer/shell/entries.cpp @@ -45,6 +45,7 @@ Entry::Entry(ENTRY_TYPE etype) _bhfi_valid = false; _level = 0; _hIcon = 0; + _display_name = _data.cFileName; } Entry::Entry(Entry* parent) @@ -58,6 +59,7 @@ Entry::Entry(Entry* parent) _bhfi_valid = false; _level = 0; _hIcon = 0; + _display_name = _data.cFileName; } // free a directory entry @@ -65,6 +67,9 @@ Entry::~Entry() { if (_hIcon && _hIcon!=(HICON)-1) DestroyIcon(_hIcon); + + if (_display_name != _data.cFileName) + free(_display_name); } diff --git a/reactos/subsys/system/explorer/shell/entries.h b/reactos/subsys/system/explorer/shell/entries.h index 50f3ce9df46..481e97677ca 100644 --- a/reactos/subsys/system/explorer/shell/entries.h +++ b/reactos/subsys/system/explorer/shell/entries.h @@ -61,6 +61,7 @@ public: WIN32_FIND_DATA _data; SFGAOF _shell_attribs; + LPTSTR _display_name; ENTRY_TYPE _etype; HICON _hIcon; diff --git a/reactos/subsys/system/explorer/shell/filechild.cpp b/reactos/subsys/system/explorer/shell/filechild.cpp index 8ee4c32e8d2..5b6518a4941 100644 --- a/reactos/subsys/system/explorer/shell/filechild.cpp +++ b/reactos/subsys/system/explorer/shell/filechild.cpp @@ -407,10 +407,10 @@ void FileChildWindow::activate_entry(Pane* pane, HWND hwnd) if (!scanned_old) scan_entry(entry, hwnd); - if (entry->_data.cFileName[0]=='.' && entry->_data.cFileName[1]=='\0') + if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('\0')) return; - if (entry->_data.cFileName[0]=='.' && entry->_data.cFileName[1]=='.' && entry->_data.cFileName[2]=='\0') { + if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('.') && entry->_data.cFileName[2]==TEXT('\0')) { entry = _left->_cur->_up; collapse_entry(_left, entry); goto focus_entry; diff --git a/reactos/subsys/system/explorer/shell/pane.cpp b/reactos/subsys/system/explorer/shell/pane.cpp index eee95bc0e67..3e15b3934f0 100644 --- a/reactos/subsys/system/explorer/shell/pane.cpp +++ b/reactos/subsys/system/explorer/shell/pane.cpp @@ -353,7 +353,7 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol) else img = IMG_FOLDER; } else { - LPCTSTR ext = _tcsrchr(entry->_data.cFileName, '.'); + LPCTSTR ext = _tcsrchr(entry->_data.cFileName, TEXT('.')); if (!ext) ext = TEXT(""); @@ -498,9 +498,9 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol) // ouput file name if (calcWidthCol == -1) - _out_wrkr.output_text(dis, _positions, col, entry->_data.cFileName, 0); + _out_wrkr.output_text(dis, _positions, col, entry->_display_name, 0); else if (calcWidthCol==col || calcWidthCol==COLUMNS) - calc_width(dis, col, entry->_data.cFileName); + calc_width(dis, col, entry->_display_name); ++col; diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index 9d445cb7e3c..54b2e750a84 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -79,7 +79,7 @@ LRESULT ShellBrowserChild::Init(LPCREATESTRUCT pcs) ClientRect rect(_hwnd); - SHFILEINFO sfi; + SHFILEINFO sfi; _himlSmall = (HIMAGELIST)SHGetFileInfo(TEXT("C:\\"), 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_SMALLICON); // _himlLarge = (HIMAGELIST)SHGetFileInfo(TEXT("C:\\"), 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_LARGEICON); @@ -276,18 +276,21 @@ void ShellBrowserChild::OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh) LPNMTVDISPINFO lpdi = (LPNMTVDISPINFO)pnmh; ShellEntry* entry = (ShellEntry*)lpdi->item.lParam; - if (lpdi->item.mask & TVIF_TEXT) { - /* if (SHGetFileInfo((LPCTSTR)&*entry->_pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_DISPLAYNAME)) - lstrcpy(lpdi->item.pszText, sfi.szDisplayName); */ - lstrcpy(lpdi->item.pszText, entry->_data.cFileName); - } + if (lpdi->item.mask & TVIF_TEXT) + lpdi->item.pszText = entry->_display_name; - if (lpdi->item.mask & (TVIF_IMAGE|TVIF_SELECTEDIMAGE)) { + if (lpdi->item.mask & (/*TVIF_TEXT|*/TVIF_IMAGE|TVIF_SELECTEDIMAGE)) { ShellPath pidl_abs = entry->create_absolute_pidl(); // Caching of absolute PIDLs could enhance performance. LPCITEMIDLIST pidl = pidl_abs; SHFILEINFO sfi; - +/* + if (lpdi->item.mask & TVIF_TEXT) + if (SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_DISPLAYNAME)) + lstrcpy(lpdi->item.pszText, sfi.szDisplayName); //TODO: look at cchTextMax if there is enough space available + else + lpdi->item.pszText = entry->_data.cFileName; +*/ if (lpdi->item.mask & TVIF_IMAGE) if ((HIMAGELIST)SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_LINKOVERLAY) == _himlSmall) lpdi->item.iImage = sfi.iIcon; @@ -311,6 +314,8 @@ void ShellBrowserChild::OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv) if (entry) if (!InsertSubitems(pnmtv->itemNew.hItem, entry, entry->_folder)) { + entry->_shell_attribs &= ~SFGAO_HASSUBFOLDER; + // remove subitem "+" TV_ITEM tvItem; diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index d405f1297c6..d98b0b9bf35 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -58,6 +58,9 @@ bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN LPCTSTR path = (LPCTSTR)GlobalLock(medium.UNION_MEMBER(hGlobal)); UINT sem_org = SetErrorMode(SEM_FAILCRITICALERRORS); + // fill out drive names "C:", ... + _tcscpy(pw32fdata->cFileName, path); + if (GetFileAttributesEx(path, GetFileExInfoStandard, &fad)) { pw32fdata->dwFileAttributes = fad.dwFileAttributes; pw32fdata->ftCreationTime = fad.ftCreationTime; @@ -281,8 +284,12 @@ void ShellDirectory::read_directory() if (bhfi_valid) memcpy(&entry->_bhfi, &bhfi, sizeof(BY_HANDLE_FILE_INFORMATION)); - if (SUCCEEDED(name_from_pidl(_folder, pidls[n], name, MAX_PATH, SHGDN_INFOLDER|0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/))) - _tcscpy(entry->_data.cFileName, name); + if (SUCCEEDED(name_from_pidl(_folder, pidls[n], name, MAX_PATH, SHGDN_INFOLDER|0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/))) { + if (!entry->_data.cFileName[0]) + _tcscpy(entry->_data.cFileName, name); + else if (_tcscmp(entry->_display_name, name)) + entry->_display_name = _tcsdup(name); // store display name separate from file name; sort display by file name + } // get display icons for files and virtual objects if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index 5dd42a8c189..9f4845f1524 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -298,7 +298,7 @@ StartMenuEntry& StartMenu::AddEntry(const ShellFolder folder, const ShellEntry* for(ShellEntryMap::iterator it=_entries.begin(); it!=_entries.end(); ++it) { StartMenuEntry& sme = it->second; - if (sme._title == entry_name) + if (sme._title == entry_name) //TODO: speed up by using a map indexed by name for(ShellEntrySet::iterator it2=sme._entries.begin(); it2!=sme._entries.end(); ++it2) { if ((*it2)->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // merge the new shell entry with the existing of the same name