reinitialize image list in ShellBrowser::invalidate_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 } else
194 _pDropTarget->Release();
195
196 FORMATETC ftetc;
197
198 ftetc.dwAspect = DVASPECT_CONTENT;
199 ftetc.lindex = -1;
200 ftetc.tymed = TYMED_HGLOBAL;
201 ftetc.cfFormat = CF_HDROP;
202
203 _pDropTarget->AddSuportedFormat(ftetc);
204
205 return true;
206 }
207
208
209 void ShellBrowser::OnTreeItemRClick(int idCtrl, LPNMHDR pnmh)
210 {
211 CONTEXT("ShellBrowser::OnTreeItemRClick()");
212
213 TVHITTESTINFO tvhti;
214
215 GetCursorPos(&tvhti.pt);
216 ScreenToClient(_left_hwnd, &tvhti.pt);
217
218 tvhti.flags = LVHT_NOWHERE;
219 (void)TreeView_HitTest(_left_hwnd, &tvhti);
220
221 if (TVHT_ONITEM & tvhti.flags) {
222 LPARAM itemData = TreeView_GetItemData(_left_hwnd, tvhti.hItem);
223
224 if (itemData) {
225 Entry* entry = (Entry*)itemData;
226 ClientToScreen(_left_hwnd, &tvhti.pt);
227
228 CHECKERROR(entry->do_context_menu(_hwnd, tvhti.pt, _cm_ifs));
229 }
230 }
231 }
232
233 void ShellBrowser::OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh)
234 {
235 CONTEXT("ShellBrowser::OnTreeGetDispInfo()");
236
237 LPNMTVDISPINFO lpdi = (LPNMTVDISPINFO)pnmh;
238 ShellEntry* entry = (ShellEntry*)lpdi->item.lParam;
239
240 if (entry) {
241 if (lpdi->item.mask & TVIF_TEXT)
242 lpdi->item.pszText = entry->_display_name;
243
244 if (lpdi->item.mask & (TVIF_IMAGE|TVIF_SELECTEDIMAGE)) {
245 if (lpdi->item.mask & TVIF_IMAGE)
246 lpdi->item.iImage = get_image_idx(
247 entry->safe_extract_icon((ICONCACHE_FLAGS)(ICF_HICON|ICF_OVERLAYS)));
248
249 if (lpdi->item.mask & TVIF_SELECTEDIMAGE)
250 lpdi->item.iSelectedImage = get_image_idx(
251 entry->safe_extract_icon((ICONCACHE_FLAGS)(ICF_HICON|ICF_OVERLAYS|ICF_OPEN)));
252 }
253 }
254 }
255
256 int ShellBrowser::get_image_idx(int icon_id)
257 {
258 if (icon_id != ICID_NONE) {
259 map<int,int>::const_iterator found = _image_map.find(icon_id);
260
261 if (found != _image_map.end())
262 return found->second;
263
264 int idx = ImageList_AddIcon(_himl, g_Globals._icon_cache.get_icon(icon_id).get_hicon());
265
266 _image_map[icon_id] = idx;
267
268 return idx;
269 } else
270 return -1;
271 }
272
273 void ShellBrowser::invalidate_cache()
274 {
275 (void)TreeView_SetImageList(_left_hwnd, _himl_old, TVSIL_NORMAL);
276 ImageList_Destroy(_himl);
277
278 _himl_old = TreeView_SetImageList(_left_hwnd, _himl, TVSIL_NORMAL);
279 _himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0);
280
281 for(map<int,int>::const_iterator it=_image_map.begin(); it!=_image_map.end(); ++it)
282 g_Globals._icon_cache.free_icon(it->first);
283
284 _image_map.clear();
285 }
286
287 void ShellBrowser::OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv)
288 {
289 CONTEXT("ShellBrowser::OnTreeItemExpanding()");
290
291 if (pnmtv->action == TVE_COLLAPSE)
292 TreeView_Expand(_left_hwnd, pnmtv->itemNew.hItem, TVE_COLLAPSE|TVE_COLLAPSERESET);
293 else if (pnmtv->action == TVE_EXPAND) {
294 ShellDirectory* entry = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, pnmtv->itemNew.hItem);
295
296 if (entry)
297 if (!InsertSubitems(pnmtv->itemNew.hItem, entry, entry->_folder)) {
298 entry->_shell_attribs &= ~SFGAO_HASSUBFOLDER;
299
300 // remove subitem "+"
301 TV_ITEM tvItem;
302
303 tvItem.mask = TVIF_CHILDREN;
304 tvItem.hItem = pnmtv->itemNew.hItem;
305 tvItem.cChildren = 0;
306
307 TreeView_SetItem(_left_hwnd, &tvItem);
308 }
309 }
310 }
311
312 int ShellBrowser::InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder)
313 {
314 CONTEXT("ShellBrowser::InsertSubitems()");
315
316 WaitCursor wait;
317
318 int cnt = 0;
319
320 SendMessage(_left_hwnd, WM_SETREDRAW, FALSE, 0);
321
322 try {
323 entry->smart_scan();
324 } catch(COMException& e) {
325 HandleException(e, g_Globals._hMainWnd);
326 }
327
328 TV_ITEM tvItem;
329 TV_INSERTSTRUCT tvInsert;
330
331 for(entry=entry->_down; entry; entry=entry->_next) {
332 #ifndef _LEFT_FILES
333 if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
334 #endif
335 {
336 ZeroMemory(&tvItem, sizeof(tvItem));
337
338 tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;
339 tvItem.pszText = LPSTR_TEXTCALLBACK;
340 tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK;
341 tvItem.lParam = (LPARAM)entry;
342 tvItem.cChildren = entry->_shell_attribs & SFGAO_HASSUBFOLDER? 1: 0;
343
344 if (entry->_shell_attribs & SFGAO_SHARE) {
345 tvItem.mask |= TVIF_STATE;
346 tvItem.stateMask |= TVIS_OVERLAYMASK;
347 tvItem.state |= INDEXTOOVERLAYMASK(1);
348 }
349
350 tvInsert.item = tvItem;
351 tvInsert.hInsertAfter = TVI_LAST;
352 tvInsert.hParent = hParentItem;
353
354 (void)TreeView_InsertItem(_left_hwnd, &tvInsert);
355 }
356
357 ++cnt;
358 }
359
360 SendMessage(_left_hwnd, WM_SETREDRAW, TRUE, 0);
361
362 return cnt;
363 }
364
365 void ShellBrowser::OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv)
366 {
367 CONTEXT("ShellBrowser::OnTreeItemSelected()");
368
369 ShellEntry* entry = (ShellEntry*)pnmtv->itemNew.lParam;
370
371 _last_sel = pnmtv->itemNew.hItem;
372
373 if (entry)
374 _callback->entry_selected(entry);
375 }
376
377 void ShellBrowser::UpdateFolderView(IShellFolder* folder)
378 {
379 CONTEXT("ShellBrowser::UpdateFolderView()");
380
381 FOLDERSETTINGS fs;
382 IShellView* pLastShellView = _pShellView;
383
384 _folder = folder;
385
386 if (pLastShellView)
387 pLastShellView->GetCurrentInfo(&fs);
388 else {
389 fs.ViewMode = _create_info._open_mode&OWM_DETAILS? FVM_DETAILS: FVM_ICON;
390 fs.fFlags = FWF_NOCLIENTEDGE|FWF_BESTFITWINDOW;
391 }
392
393 #ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
394 SFV_CREATE sfv_create;
395
396 sfv_create.cbSize = sizeof(SFV_CREATE);
397 sfv_create.pshf = folder;
398 sfv_create.psvOuter = NULL;
399 sfv_create.psfvcb = this;
400
401 HRESULT hr = SHCreateShellFolderView(&sfv_create, &_pShellView);
402 #else
403 HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
404 #endif
405
406 if (FAILED(hr)) {
407 _pShellView = NULL;
408 return;
409 }
410
411 RECT rect = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT};
412 hr = _pShellView->CreateViewWindow(pLastShellView, &fs, static_cast<IShellBrowser*>(this), &rect, &_right_hwnd/*&m_hWndListView*/);
413
414 if (pLastShellView) {
415 pLastShellView->GetCurrentInfo(&fs);
416 pLastShellView->UIActivate(SVUIA_DEACTIVATE);
417 pLastShellView->DestroyViewWindow();
418 pLastShellView->Release();
419 }
420
421 _pShellView->UIActivate(SVUIA_ACTIVATE_NOFOCUS);
422 }
423
424
425 #ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
426
427 /// shell view callback
428 HRESULT STDMETHODCALLTYPE ShellBrowser::MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
429 {
430 if (uMsg == SFVM_INITMENUPOPUP) {
431 //@todo never reached
432 InsertMenu((HMENU)lParam, 0, MF_BYPOSITION, 12345, TEXT("TEST ENTRY"));
433 return S_OK;
434 }
435
436 return E_NOTIMPL;
437 }
438
439 #endif
440
441
442 HRESULT ShellBrowser::OnDefaultCommand(LPIDA pida)
443 {
444 CONTEXT("ShellBrowser::OnDefaultCommand()");
445
446 if (pida->cidl >= 1) {
447 if (_left_hwnd) { // explorer mode
448 if (_last_sel) {
449 ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel);
450
451 if (parent) {
452 try {
453 parent->smart_scan();
454 } catch(COMException& e) {
455 return e.Error();
456 }
457
458 UINT firstOffset = pida->aoffset[1];
459 LPITEMIDLIST pidl = (LPITEMIDLIST)((LPBYTE)pida+firstOffset);
460
461 Entry* entry = parent->find_entry(pidl);
462
463 if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
464 if (entry->_etype == ET_SHELL)
465 if (_last_sel && select_entry(_last_sel, entry))
466 return S_OK;
467 }
468 }
469 } else { // no tree control
470 if (MainFrameBase::OpenShellFolders(pida, _hWndFrame))
471 return S_OK;
472
473 /* create new Frame Window
474 if (MainFrame::OpenShellFolders(pida, 0))
475 return S_OK;
476 */
477 }
478 }
479
480 return E_NOTIMPL;
481 }
482
483
484 HTREEITEM ShellBrowser::select_entry(HTREEITEM hitem, Entry* entry, bool expand)
485 {
486 CONTEXT("ShellBrowser::select_entry()");
487
488 if (expand && !TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND))
489 return 0;
490
491 for(hitem=TreeView_GetChild(_left_hwnd,hitem); hitem; hitem=TreeView_GetNextSibling(_left_hwnd,hitem)) {
492 if ((Entry*)TreeView_GetItemData(_left_hwnd,hitem) == entry) {
493 if (TreeView_SelectItem(_left_hwnd, hitem)) {
494 if (expand)
495 TreeView_Expand(_left_hwnd, hitem, TVE_EXPAND);
496
497 return hitem;
498 }
499
500 break;
501 }
502 }
503
504 return 0;
505 }
506
507
508 bool ShellBrowser::jump_to_pidl(LPCITEMIDLIST pidl)
509 {
510 if (!_root._entry)
511 return false;
512
513 // iterate through the hierarchy and open all folders to reach pidl
514 WaitCursor wait;
515
516 HTREEITEM hitem = TreeView_GetRoot(_left_hwnd);
517 Entry* entry = _root._entry;
518
519 for(const void*p=pidl;;) {
520 if (!p)
521 return true;
522
523 if (!entry || !hitem)
524 break;
525
526 entry->smart_scan(SORT_NAME);
527
528 Entry* found = entry->find_entry(p);
529 p = entry->get_next_path_component(p);
530
531 if (found)
532 hitem = select_entry(hitem, found);
533
534 entry = found;
535 }
536
537 return false;
538 }
539
540
541 #ifndef _NO_MDI
542
543 MDIShellBrowserChild::MDIShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info)
544 : super(hwnd, info),
545 _create_info(info),
546 _shellpath_info(info) //@@ copies info -> no referenz to _create_info !
547 {
548 /**todo Conversion of shell path into path string -> store into URL history
549 const String& path = GetDesktopFolder().get_name(info._shell_path, SHGDN_FORADDRESSBAR);
550 const String& parsingpath = GetDesktopFolder().get_name(info._shell_path, SHGDN_FORPARSING);
551
552 // store path into history
553 if (info._path && *info._path)
554 _url_history.push(info._path);
555 */
556 }
557
558
559 MDIShellBrowserChild* MDIShellBrowserChild::create(const ShellChildWndInfo& info)
560 {
561 ChildWindow* child = ChildWindow::create(info, info._pos.rcNormalPosition,
562 WINDOW_CREATOR_INFO(MDIShellBrowserChild,ShellChildWndInfo), CLASSNAME_CHILDWND, NULL, info._pos.showCmd==SW_SHOWMAXIMIZED? WS_MAXIMIZE: 0);
563
564 return static_cast<MDIShellBrowserChild*>(child);
565 }
566
567
568 LRESULT MDIShellBrowserChild::Init(LPCREATESTRUCT pcs)
569 {
570 CONTEXT("MDIShellBrowserChild::Init()");
571
572 if (super::Init(pcs))
573 return 1;
574
575 update_shell_browser();
576
577 if (_shellBrowser.get())
578 if (_left_hwnd)
579 _shellBrowser->Init();
580 else
581 _shellBrowser->UpdateFolderView(_create_info._shell_path.get_folder());
582
583 return 0;
584 }
585
586
587 LRESULT MDIShellBrowserChild::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
588 {
589 switch(nmsg) {
590 case PM_DISPATCH_COMMAND: {
591 switch(LOWORD(wparam)) {
592 case ID_WINDOW_NEW: {CONTEXT("MDIShellBrowserChild PM_DISPATCH_COMMAND ID_WINDOW_NEW");
593 MDIShellBrowserChild::create(_create_info);
594 break;}
595
596 case ID_REFRESH:
597 //@todo refresh shell child
598 _shellBrowser->invalidate_cache();
599 break;
600
601 case ID_VIEW_SDI:
602 MainFrameBase::Create(ExplorerCmd(_url, false));
603 break;
604
605 default:
606 return super::WndProc(nmsg, wparam, lparam);
607 }
608 return TRUE;}
609
610 default:
611 return super::WndProc(nmsg, wparam, lparam);
612 }
613
614 return 0;
615 }
616
617 void MDIShellBrowserChild::update_shell_browser()
618 {
619 int split_pos = DEFAULT_SPLIT_POS;
620
621 if (_shellBrowser.get()) {
622 split_pos = _split_pos;
623 delete _shellBrowser.release();
624 }
625
626 ///@todo use OWM_ROOTED flag
627
628 // create explorer treeview
629 if (_create_info._open_mode & OWM_EXPLORE) {
630 if (!_left_hwnd) {
631 ClientRect rect(_hwnd);
632
633 _left_hwnd = CreateWindowEx(0, WC_TREEVIEW, NULL,
634 WS_CHILD|WS_TABSTOP|WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,//|TVS_NOTOOLTIPS
635 0, rect.top, split_pos-SPLIT_WIDTH/2, rect.bottom-rect.top,
636 _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0);
637 }
638 } else {
639 if (_left_hwnd) {
640 DestroyWindow(_left_hwnd);
641 _left_hwnd = 0;
642 }
643 }
644
645 _shellBrowser = auto_ptr<ShellBrowser>(new ShellBrowser(_hwnd, _left_hwnd, _right_hwnd,
646 _shellpath_info, this, _cm_ifs));
647
648 _shellBrowser->Init(_hwndFrame);
649 }
650
651
652 String MDIShellBrowserChild::jump_to_int(LPCTSTR url)
653 {
654 String dir, fname;
655
656 if (!_tcsnicmp(url, TEXT("shell://"), 8)) {
657 if (_shellBrowser->jump_to_pidl(ShellPath(url+8)))
658 return url;
659 }
660
661 if (SplitFileSysURL(url, dir, fname)) {
662
663 ///@todo use fname
664
665 if (_shellBrowser->jump_to_pidl(ShellPath(dir)))
666 return FmtString(TEXT("file://%s"), (LPCTSTR)dir);
667 }
668
669 return String();
670 }
671
672
673 void MDIShellBrowserChild::entry_selected(Entry* entry)
674 {
675 if (entry->_etype == ET_SHELL) {
676 ShellEntry* shell_entry = static_cast<ShellEntry*>(entry);
677 IShellFolder* folder;
678
679 if (shell_entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
680 folder = static_cast<ShellDirectory*>(shell_entry)->_folder;
681 else
682 folder = shell_entry->get_parent_folder();
683
684 if (!folder) {
685 assert(folder);
686 return;
687 }
688
689 TCHAR path[MAX_PATH];
690
691 if (shell_entry->get_path(path, COUNTOF(path))) {
692 String url;
693
694 if (path[0] == ':')
695 url.printf(TEXT("shell://%s"), path);
696 else
697 url.printf(TEXT("file://%s"), path);
698
699 set_url(url);
700 }
701
702 _shellBrowser->UpdateFolderView(folder);
703
704 // set size of new created shell view windows
705 ClientRect rt(_hwnd);
706 resize_children(rt.right, rt.bottom);
707 }
708 }
709
710 #endif