- refactor icon cache
[reactos.git] / reactos / subsys / system / explorer / shell / shellbrowser.cpp
1 /*
2 * Copyright 2003, 2004, 2005 Martin Fuchs
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20 //
21 // Explorer clone
22 //
23 // shellbrowser.cpp
24 //
25 // Martin Fuchs, 23.07.2003
26 //
27
28
29 #include <precomp.h>
30
31 #include "../resource.h"
32
33
34 // work around GCC's wide string constant bug
35 #ifdef __GNUC__
36 const LPCTSTR C_DRIVE = C_DRIVE_STR;
37 #endif
38
39
40 ShellBrowser::ShellBrowser(HWND hwnd, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info,
41 BrowserCallback* cb, CtxMenuInterfaces& cm_ifs)
42 #ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
43 : super(IID_IShellFolderViewCB),
44 #else
45 :
46 #endif
47 _hwnd(hwnd),
48 _left_hwnd(left_hwnd),
49 _right_hwnd(right_hwnd),
50 _create_info(create_info),
51 _callback(cb),
52 _cm_ifs(cm_ifs)
53 {
54 _pShellView = NULL;
55 _pDropTarget = NULL;
56 _last_sel = 0;
57
58 _cur_dir = NULL;
59
60 _himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0);
61 ImageList_SetBkColor(_himl, GetSysColor(COLOR_WINDOW));
62 }
63
64 ShellBrowser::~ShellBrowser()
65 {
66 (void)TreeView_SetImageList(_left_hwnd, _himl_old, TVSIL_NORMAL);
67 ImageList_Destroy(_himl);
68
69 if (_pShellView)
70 _pShellView->Release();
71
72 if (_pDropTarget) {
73 _pDropTarget->Release();
74 _pDropTarget = NULL;
75 }
76
77 if (_right_hwnd) {
78 DestroyWindow(_right_hwnd);
79 _right_hwnd = 0;
80 }
81 }
82
83
84 LRESULT ShellBrowser::Init(HWND hWndFrame)
85 {
86 CONTEXT("ShellBrowser::Init()");
87
88 _hWndFrame = hWndFrame;
89
90 const String& root_name = GetDesktopFolder().get_name(_create_info._root_shell_path, SHGDN_FORADDRESSBAR);
91
92 _root._drive_type = DRIVE_UNKNOWN;
93 lstrcpy(_root._volname, root_name);
94 _root._fs_flags = 0;
95 lstrcpy(_root._fs, TEXT("Desktop"));
96
97 _root._entry = new ShellDirectory(GetDesktopFolder(), _create_info._root_shell_path, _hwnd);
98
99 jump_to(_create_info._shell_path);
100
101 // -> set_curdir()
102 _root._entry->read_directory();
103
104 /* already filled by ShellDirectory constructor
105 lstrcpy(_root._entry->_data.cFileName, TEXT("Desktop")); */
106
107 return 0;
108 }
109
110 void ShellBrowser::jump_to(LPCITEMIDLIST pidl)
111 {
112 Entry* entry = NULL;
113
114 //@@
115 if (!_cur_dir)
116 _cur_dir = static_cast<ShellDirectory*>(_root._entry);
117
118 //LOG(FmtString(TEXT("ShellBrowser::jump_to(): pidl=%s"), (LPCTSTR)FileSysShellPath(pidl)));
119
120 if (_cur_dir) {
121 static DynamicFct<LPITEMIDLIST(WINAPI*)(LPCITEMIDLIST, LPCITEMIDLIST)> ILFindChild(TEXT("SHELL32"), 24);
122
123 /*@todo
124 we should call read_tree() here to iterate through the hierarchy and open all folders from _create_info._root_shell_path (_cur_dir) to _create_info._shell_path (pidl)
125 _root._entry->read_tree(_create_info._root_shell_path.get_folder(), info._shell_path, SORT_NAME);
126 -> see FileChildWindow::FileChildWindow()_create_info._shell_path
127 */
128
129 LPCITEMIDLIST child_pidl;
130
131 if (ILFindChild)
132 child_pidl = (*ILFindChild)(_cur_dir->create_absolute_pidl(), pidl);
133 else
134 child_pidl = pidl; // This is not correct in the common case, but works on the desktop level.
135
136 if (child_pidl) {
137 _cur_dir->smart_scan();
138
139 entry = _cur_dir->find_entry(child_pidl);
140
141 if (entry) {
142 _cur_dir = static_cast<ShellDirectory*>(entry);
143 _callback->entry_selected(entry);
144 }
145 }
146 }
147
148 //@@ work around as long as we don't iterate correctly through the ShellEntry tree
149 if (!entry)
150 UpdateFolderView(ShellFolder(pidl));
151 }
152
153
154 void ShellBrowser::InitializeTree()
155 {
156 CONTEXT("ShellBrowserChild::InitializeTree()");
157
158 _himl_old = TreeView_SetImageList(_left_hwnd, _himl, TVSIL_NORMAL);
159 TreeView_SetScrollTime(_left_hwnd, 100);
160
161 TV_INSERTSTRUCT tvInsert;
162 TV_ITEM& tvItem = tvInsert.item;
163
164 tvInsert.hParent = 0;
165 tvInsert.hInsertAfter = TVI_LAST;
166
167 tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;
168 tvItem.lParam = (LPARAM)_root._entry;
169 tvItem.pszText = _root._volname; //LPSTR_TEXTCALLBACK;
170 tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK;
171 tvItem.cChildren = 1;
172
173 HTREEITEM hItem = TreeView_InsertItem(_left_hwnd, &tvInsert);
174 TreeView_SelectItem(_left_hwnd, hItem);
175 TreeView_Expand(_left_hwnd, hItem, TVE_EXPAND);
176 }
177
178 bool ShellBrowser::InitDragDrop()
179 {
180 CONTEXT("ShellBrowser::InitDragDrop()");
181
182 _pDropTarget = new TreeDropTarget(_left_hwnd);
183
184 if (!_pDropTarget)
185 return false;
186
187 _pDropTarget->AddRef();
188
189 if (FAILED(RegisterDragDrop(_left_hwnd, _pDropTarget))) {//calls addref
190 _pDropTarget->Release(); // free TreeDropTarget
191 _pDropTarget = NULL;
192 return false;
193 }
194 else
195 _pDropTarget->Release();
196
197 FORMATETC ftetc;
198
199 ftetc.dwAspect = DVASPECT_CONTENT;
200 ftetc.lindex = -1;
201 ftetc.tymed = TYMED_HGLOBAL;
202 ftetc.cfFormat = CF_HDROP;
203
204 _pDropTarget->AddSuportedFormat(ftetc);
205
206 return true;
207 }
208
209
210 void ShellBrowser::OnTreeItemRClick(int idCtrl, LPNMHDR pnmh)
211 {
212 CONTEXT("ShellBrowser::OnTreeItemRClick()");
213
214 TVHITTESTINFO tvhti;
215
216 GetCursorPos(&tvhti.pt);
217 ScreenToClient(_left_hwnd, &tvhti.pt);
218
219 tvhti.flags = LVHT_NOWHERE;
220 (void)TreeView_HitTest(_left_hwnd, &tvhti);
221
222 if (TVHT_ONITEM & tvhti.flags) {
223 LPARAM itemData = TreeView_GetItemData(_left_hwnd, tvhti.hItem);
224
225 if (itemData) {
226 Entry* entry = (Entry*)itemData;
227 ClientToScreen(_left_hwnd, &tvhti.pt);
228
229 CHECKERROR(entry->do_context_menu(_hwnd, tvhti.pt, _cm_ifs));
230 }
231 }
232 }
233
234 void ShellBrowser::OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh)
235 {
236 CONTEXT("ShellBrowser::OnTreeGetDispInfo()");
237
238 LPNMTVDISPINFO lpdi = (LPNMTVDISPINFO)pnmh;
239 ShellEntry* entry = (ShellEntry*)lpdi->item.lParam;
240
241 if (entry) {
242 if (lpdi->item.mask & TVIF_TEXT)
243 lpdi->item.pszText = entry->_display_name;
244
245 if (lpdi->item.mask & (TVIF_IMAGE|TVIF_SELECTEDIMAGE)) {
246 if (lpdi->item.mask & TVIF_IMAGE)
247 lpdi->item.iImage = get_image_idx(
248 entry->safe_extract_icon((ICONCACHE_FLAGS)(ICF_HICON|ICF_OVERLAYS)));
249
250 if (lpdi->item.mask & TVIF_SELECTEDIMAGE)
251 lpdi->item.iSelectedImage = get_image_idx(
252 entry->safe_extract_icon((ICONCACHE_FLAGS)(ICF_HICON|ICF_OVERLAYS|ICF_OPEN)));
253 }
254 }
255 }
256
257 int ShellBrowser::get_image_idx(int icon_id)
258 {
259 if (icon_id != ICID_NONE) {
260 map<int,int>::const_iterator found = _image_map.find(icon_id);
261
262 if (found != _image_map.end())
263 return found->second;
264
265 int idx = ImageList_AddIcon(_himl, g_Globals._icon_cache.get_icon(icon_id).get_hicon());
266
267 _image_map[icon_id] = idx;
268
269 return idx;
270 } else
271 return -1;
272 }
273
274 void ShellBrowser::invalidate_cache()
275 {
276 for(map<int,int>::const_iterator it=_image_map.begin(); it!=_image_map.end(); ++it)
277 g_Globals._icon_cache.free_icon(it->first);
278
279 _image_map.clear();
280 }
281
282 void ShellBrowser::OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv)
283 {
284 CONTEXT("ShellBrowser::OnTreeItemExpanding()");
285
286 if (pnmtv->action == TVE_COLLAPSE)
287 TreeView_Expand(_left_hwnd, pnmtv->itemNew.hItem, TVE_COLLAPSE|TVE_COLLAPSERESET);
288 else if (pnmtv->action == TVE_EXPAND) {
289 ShellDirectory* entry = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, pnmtv->itemNew.hItem);
290
291 if (entry)
292 if (!InsertSubitems(pnmtv->itemNew.hItem, entry, entry->_folder)) {
293 entry->_shell_attribs &= ~SFGAO_HASSUBFOLDER;
294
295 // remove subitem "+"
296 TV_ITEM tvItem;
297
298 tvItem.mask = TVIF_CHILDREN;
299 tvItem.hItem = pnmtv->itemNew.hItem;
300 tvItem.cChildren = 0;
301
302 TreeView_SetItem(_left_hwnd, &tvItem);
303 }
304 }
305 }
306
307 int ShellBrowser::InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder)
308 {
309 CONTEXT("ShellBrowser::InsertSubitems()");
310
311 WaitCursor wait;
312
313 int cnt = 0;
314
315 SendMessage(_left_hwnd, WM_SETREDRAW, FALSE, 0);
316
317 try {
318 entry->smart_scan();
319 } catch(COMException& e) {
320 HandleException(e, g_Globals._hMainWnd);
321 }
322
323 TV_ITEM tvItem;
324 TV_INSERTSTRUCT tvInsert;
325
326 for(entry=entry->_down; entry; entry=entry->_next) {
327 #ifndef _LEFT_FILES
328 if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
329 #endif
330 {
331 ZeroMemory(&tvItem, sizeof(tvItem));
332
333 tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;
334 tvItem.pszText = LPSTR_TEXTCALLBACK;
335 tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK;
336 tvItem.lParam = (LPARAM)entry;
337 tvItem.cChildren = entry->_shell_attribs & SFGAO_HASSUBFOLDER? 1: 0;
338
339 if (entry->_shell_attribs & SFGAO_SHARE) {
340 tvItem.mask |= TVIF_STATE;
341 tvItem.stateMask |= TVIS_OVERLAYMASK;
342 tvItem.state |= INDEXTOOVERLAYMASK(1);
343 }
344
345 tvInsert.item = tvItem;
346 tvInsert.hInsertAfter = TVI_LAST;
347 tvInsert.hParent = hParentItem;
348
349 (void)TreeView_InsertItem(_left_hwnd, &tvInsert);
350 }
351
352 ++cnt;
353 }
354
355 SendMessage(_left_hwnd, WM_SETREDRAW, TRUE, 0);
356
357 return cnt;
358 }
359
360 void ShellBrowser::OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv)
361 {
362 CONTEXT("ShellBrowser::OnTreeItemSelected()");
363
364 ShellEntry* entry = (ShellEntry*)pnmtv->itemNew.lParam;
365
366 _last_sel = pnmtv->itemNew.hItem;
367
368 if (entry)
369 _callback->entry_selected(entry);
370 }
371
372 void ShellBrowser::UpdateFolderView(IShellFolder* folder)
373 {
374 CONTEXT("ShellBrowser::UpdateFolderView()");
375
376 FOLDERSETTINGS fs;
377 IShellView* pLastShellView = _pShellView;
378
379 _folder = folder;
380
381 if (pLastShellView)
382 pLastShellView->GetCurrentInfo(&fs);
383 else {
384 fs.ViewMode = _create_info._open_mode&OWM_DETAILS? FVM_DETAILS: FVM_ICON;
385 fs.fFlags = FWF_NOCLIENTEDGE|FWF_BESTFITWINDOW;
386 }
387
388 #ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
389 SFV_CREATE sfv_create;
390
391 sfv_create.cbSize = sizeof(SFV_CREATE);
392 sfv_create.pshf = folder;
393 sfv_create.psvOuter = NULL;
394 sfv_create.psfvcb = this;
395
396 HRESULT hr = SHCreateShellFolderView(&sfv_create, &_pShellView);
397 #else
398 HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
399 #endif
400
401 if (FAILED(hr)) {
402 _pShellView = NULL;
403 return;
404 }
405
406 RECT rect = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT};
407 hr = _pShellView->CreateViewWindow(pLastShellView, &fs, static_cast<IShellBrowser*>(this), &rect, &_right_hwnd/*&m_hWndListView*/);
408
409 if (pLastShellView) {
410 pLastShellView->GetCurrentInfo(&fs);
411 pLastShellView->UIActivate(SVUIA_DEACTIVATE);
412 pLastShellView->DestroyViewWindow();
413 pLastShellView->Release();
414 }
415
416 _pShellView->UIActivate(SVUIA_ACTIVATE_NOFOCUS);
417 }
418
419
420 #ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
421
422 /// shell view callback
423 HRESULT STDMETHODCALLTYPE ShellBrowser::MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
424 {
425 if (uMsg == SFVM_INITMENUPOPUP) {
426 //@todo never reached
427 InsertMenu((HMENU)lParam, 0, MF_BYPOSITION, 12345, TEXT("TEST ENTRY"));
428 return S_OK;
429 }
430
431 return E_NOTIMPL;
432 }
433
434 #endif
435
436
437 HRESULT ShellBrowser::OnDefaultCommand(LPIDA pida)
438 {
439 CONTEXT("ShellBrowser::OnDefaultCommand()");
440
441 if (pida->cidl >= 1) {
442 if (_left_hwnd) { // explorer mode
443 if (_last_sel) {
444 ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel);
445
446 if (parent) {
447 try {
448 parent->smart_scan();
449 } catch(COMException& e) {
450 return e.Error();
451 }
452
453 UINT firstOffset = pida->aoffset[1];
454 LPITEMIDLIST pidl = (LPITEMIDLIST)((LPBYTE)pida+firstOffset);
455
456 Entry* entry = parent->find_entry(pidl);
457
458 if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
459 if (entry->_etype == ET_SHELL)
460 if (_last_sel && select_entry(_last_sel, entry))
461 return S_OK;
462 }
463 }
464 } else { // no tree control
465 if (MainFrameBase::OpenShellFolders(pida, _hWndFrame))
466 return S_OK;
467
468 /* create new Frame Window
469 if (MainFrame::OpenShellFolders(pida, 0))
470 return S_OK;
471 */
472 }
473 }
474
475 return E_NOTIMPL;
476 }
477
478
479 HTREEITEM ShellBrowser::select_entry(HTREEITEM hitem, Entry* entry, bool expand)
480 {
481 CONTEXT("ShellBrowser::select_entry()");
482
483 if (expand && !TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND))
484 return 0;
485
486 for(hitem=TreeView_GetChild(_left_hwnd,hitem); hitem; hitem=TreeView_GetNextSibling(_left_hwnd,hitem)) {
487 if ((Entry*)TreeView_GetItemData(_left_hwnd,hitem) == entry) {
488 if (TreeView_SelectItem(_left_hwnd, hitem)) {
489 if (expand)
490 TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND);
491
492 return hitem;
493 }
494
495 break;
496 }
497 }
498
499 return 0;
500 }
501
502
503 bool ShellBrowser::jump_to_pidl(LPCITEMIDLIST pidl)
504 {
505 if (!_root._entry)
506 return false;
507
508 // iterate through the hierarchy and open all folders to reach pidl
509 WaitCursor wait;
510
511 HTREEITEM hitem = TreeView_GetRoot(_left_hwnd);
512 Entry* entry = _root._entry;
513
514 for(const void*p=pidl;;) {
515 if (!p)
516 return true;
517
518 if (!entry || !hitem)
519 break;
520
521 entry->smart_scan(SORT_NAME);
522
523 Entry* found = entry->find_entry(p);
524 p = entry->get_next_path_component(p);
525
526 if (found)
527 hitem = select_entry(hitem, found);
528
529 entry = found;
530 }
531
532 return false;
533 }
534
535
536 #ifndef _NO_MDI
537
538 MDIShellBrowserChild::MDIShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info)
539 : super(hwnd, info),
540 _create_info(info),
541 _shellpath_info(info) //@@ copies info -> no referenz to _create_info !
542 {
543 /**todo Conversion of shell path into path string -> store into URL history
544 const String& path = GetDesktopFolder().get_name(info._shell_path, SHGDN_FORADDRESSBAR);
545 const String& parsingpath = GetDesktopFolder().get_name(info._shell_path, SHGDN_FORPARSING);
546
547 // store path into history
548 if (info._path && *info._path)
549 _url_history.push(info._path);
550 */
551 }
552
553
554 MDIShellBrowserChild* MDIShellBrowserChild::create(const ShellChildWndInfo& info)
555 {
556 ChildWindow* child = ChildWindow::create(info, info._pos.rcNormalPosition,
557 WINDOW_CREATOR_INFO(MDIShellBrowserChild,ShellChildWndInfo), CLASSNAME_CHILDWND, NULL, info._pos.showCmd==SW_SHOWMAXIMIZED? WS_MAXIMIZE: 0);
558
559 return static_cast<MDIShellBrowserChild*>(child);
560 }
561
562
563 LRESULT MDIShellBrowserChild::Init(LPCREATESTRUCT pcs)
564 {
565 CONTEXT("MDIShellBrowserChild::Init()");
566
567 if (super::Init(pcs))
568 return 1;
569
570 update_shell_browser();
571
572 if (_shellBrowser.get())
573 if (_left_hwnd)
574 _shellBrowser->Init();
575 else
576 _shellBrowser->UpdateFolderView(_create_info._shell_path.get_folder());
577
578 return 0;
579 }
580
581
582 LRESULT MDIShellBrowserChild::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
583 {
584 switch(nmsg) {
585 case PM_DISPATCH_COMMAND: {
586 switch(LOWORD(wparam)) {
587 case ID_WINDOW_NEW: {CONTEXT("MDIShellBrowserChild PM_DISPATCH_COMMAND ID_WINDOW_NEW");
588 MDIShellBrowserChild::create(_create_info);
589 break;}
590
591 case ID_REFRESH:
592 //@todo refresh shell child
593 _shellBrowser->invalidate_cache();
594 break;
595
596 case ID_VIEW_SDI:
597 MainFrameBase::Create(ExplorerCmd(_url, false));
598 break;
599
600 default:
601 return super::WndProc(nmsg, wparam, lparam);
602 }
603 return TRUE;}
604
605 default:
606 return super::WndProc(nmsg, wparam, lparam);
607 }
608
609 return 0;
610 }
611
612 void MDIShellBrowserChild::update_shell_browser()
613 {
614 int split_pos = DEFAULT_SPLIT_POS;
615
616 if (_shellBrowser.get()) {
617 split_pos = _split_pos;
618 delete _shellBrowser.release();
619 }
620
621 ///@todo use OWM_ROOTED flag
622
623 // create explorer treeview
624 if (_create_info._open_mode & OWM_EXPLORE) {
625 if (!_left_hwnd) {
626 ClientRect rect(_hwnd);
627
628 _left_hwnd = CreateWindowEx(0, WC_TREEVIEW, NULL,
629 WS_CHILD|WS_TABSTOP|WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,//|TVS_NOTOOLTIPS
630 0, rect.top, split_pos-SPLIT_WIDTH/2, rect.bottom-rect.top,
631 _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0);
632 }
633 } else {
634 if (_left_hwnd) {
635 DestroyWindow(_left_hwnd);
636 _left_hwnd = 0;
637 }
638 }
639
640 _shellBrowser = auto_ptr<ShellBrowser>(new ShellBrowser(_hwnd, _left_hwnd, _right_hwnd,
641 _shellpath_info, this, _cm_ifs));
642
643 _shellBrowser->Init(_hwndFrame);
644 }
645
646
647 String MDIShellBrowserChild::jump_to_int(LPCTSTR url)
648 {
649 String dir, fname;
650
651 if (!_tcsnicmp(url, TEXT("shell://"), 8)) {
652 if (_shellBrowser->jump_to_pidl(ShellPath(url+8)))
653 return url;
654 }
655
656 if (SplitFileSysURL(url, dir, fname)) {
657
658 ///@todo use fname
659
660 if (_shellBrowser->jump_to_pidl(ShellPath(dir)))
661 return FmtString(TEXT("file://%s"), (LPCTSTR)dir);
662 }
663
664 return String();
665 }
666
667
668 void MDIShellBrowserChild::entry_selected(Entry* entry)
669 {
670 if (entry->_etype == ET_SHELL) {
671 ShellEntry* shell_entry = static_cast<ShellEntry*>(entry);
672 IShellFolder* folder;
673
674 if (shell_entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
675 folder = static_cast<ShellDirectory*>(shell_entry)->_folder;
676 else
677 folder = shell_entry->get_parent_folder();
678
679 if (!folder) {
680 assert(folder);
681 return;
682 }
683
684 TCHAR path[MAX_PATH];
685
686 if (shell_entry->get_path(path, COUNTOF(path))) {
687 String url;
688
689 if (path[0] == ':')
690 url.printf(TEXT("shell://%s"), path);
691 else
692 url.printf(TEXT("file://%s"), path);
693
694 set_url(url);
695 }
696
697 _shellBrowser->UpdateFolderView(folder);
698
699 // set size of new created shell view windows
700 ClientRect rt(_hwnd);
701 resize_children(rt.right, rt.bottom);
702 }
703 }
704
705 #endif