diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index d722cf135e1..fb71fafe856 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -453,7 +453,7 @@ void explorer_show_frame(int cmdshow, LPTSTR lpCmdLine) if (valid_dir) PostMessage(hMainFrame, PM_OPEN_WINDOW, 0, (LPARAM)lpCmdLine); else - PostMessage(hMainFrame, PM_OPEN_WINDOW, OWM_EXPLORE|OWM_DETAILS, 0); + PostMessage(hMainFrame, PM_OPEN_WINDOW, 0/*OWM_EXPLORE|OWM_DETAILS*/, 0); } } diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index d8b0add60b5..ab649db6097 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -73,7 +73,8 @@ MainFrame::MainFrame(HWND hwnd) _hstatusbar = CreateStatusWindow(WS_CHILD|WS_VISIBLE, 0, hwnd, IDW_STATUSBAR); CheckMenuItem(_menu_info._hMenuView, ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); - update_explorer_view(); + /* wait for PM_OPEN_WINDOW message before creating a shell view + update_explorer_view();*/ } void MainFrame::update_explorer_view() @@ -88,14 +89,16 @@ void MainFrame::update_explorer_view() // create explorer treeview if (_create_info._open_mode & OWM_EXPLORE) { if (!_left_hwnd) { - WindowCanvas canvas(_hwnd); - RECT rect = {0, 0, 0, 0}; - DrawText(canvas, TEXT("My"), -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT); + ClientRect rect(_hwnd); _left_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL, WS_CHILD|WS_TABSTOP|WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_NOTOOLTIPS|TVS_SHOWSELALWAYS, 0, rect.top, split_pos-SPLIT_WIDTH/2, rect.bottom-rect.top, _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0); + + // display tree window as long as the shell view is not yet visible + resize_frame_rect(&rect); + MoveWindow(_left_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE); } } else { if (_left_hwnd) { @@ -125,7 +128,7 @@ HWND MainFrame::Create() HMENU hMenuFrame = LoadMenu(g_Globals._hInstance, MAKEINTRESOURCE(IDM_MAINFRAME)); return super::Create(WINDOW_CREATOR(MainFrame), 0, - (LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW, + (LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0/*hwndDesktop*/, hMenuFrame); } @@ -165,20 +168,34 @@ HWND MainFrame::Create(LPCITEMIDLIST pidl, int mode) void MainFrame::jump_to(LPCTSTR path, int mode) { - _create_info._open_mode = mode; - _create_info._shell_path = path; - _create_info._root_shell_path = SpecialFolderPath(CSIDL_DRIVES, _hwnd); //@@ + if (_shellBrowser.get() && (_create_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) { + _create_info._shell_path = path; - update_explorer_view(); + LPCITEMIDLIST pidl = _create_info._shell_path; + _shellBrowser->jump_to((void*)pidl); + } else { + _create_info._open_mode = mode; + _create_info._shell_path = path; + _create_info._root_shell_path = SpecialFolderPath(CSIDL_DRIVES, _hwnd); //@@ + + update_explorer_view(); + } } void MainFrame::jump_to(LPCITEMIDLIST path, int mode) { - _create_info._open_mode = mode; - _create_info._shell_path = path; - _create_info._root_shell_path = DesktopFolderPath(); //@@ + if (_shellBrowser.get() && (_create_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) { + _create_info._shell_path = path; - update_explorer_view(); + LPCITEMIDLIST pidl = _create_info._shell_path; + _shellBrowser->jump_to((void*)pidl); + } else { + _create_info._open_mode = mode; + _create_info._shell_path = path; + _create_info._root_shell_path = DesktopFolderPath(); //@@ + + update_explorer_view(); + } } @@ -228,6 +245,10 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) return FALSE;} + case WM_ERASEBKGND: // draw empty background as long as no view is visible + FillRect((HDC)wparam, ClientRect(_hwnd), GetSysColorBrush(COLOR_BTNFACE)); + return TRUE; + case WM_CLOSE: DestroyWindow(_hwnd); g_Globals._hMainWnd = 0; @@ -285,7 +306,7 @@ LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) } jump_to(shell_path, (OPEN_WINDOW_MODE)wparam); - break;} + return TRUE;} // success case PM_GET_CONTROLWINDOW: if (wparam == FCW_STATUS) diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index d3b1e958aaf..50448664edf 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -63,6 +63,8 @@ ShellBrowserChild::ShellBrowserChild(HWND hwnd, HWND left_hwnd, WindowHandle& ri _split_pos = DEFAULT_SPLIT_POS; _last_split = DEFAULT_SPLIT_POS; + _cur_dir = NULL; + Init(hwnd); } @@ -96,14 +98,27 @@ LRESULT ShellBrowserChild::Init(HWND hWndFrame) _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); - if (_left_hwnd) { InitializeTree(); - InitDragDrop(); } - UpdateFolderView(_create_info._shell_path.get_folder()); + const String& root_name = GetDesktopFolder().get_name(_create_info._root_shell_path, SHGDN_FORPARSING); + + _root._drive_type = DRIVE_UNKNOWN; + lstrcpy(_root._volname, root_name); // most of the time "Desktop" + _root._fs_flags = 0; + lstrcpy(_root._fs, TEXT("Desktop")); + + _root._entry = new ShellDirectory(GetDesktopFolder(), _create_info._root_shell_path, _hwnd); + + jump_to((void*)(LPCITEMIDLIST)_create_info._shell_path); + + // -> set_curdir() + _root._entry->read_directory(); + + /* already filled by ShellDirectory constructor + lstrcpy(_root._entry->_data.cFileName, TEXT("Desktop")); */ return 0; } @@ -116,26 +131,6 @@ void ShellBrowserChild::InitializeTree() TreeView_SetImageList(_left_hwnd, _himlSmall, TVSIL_NORMAL); TreeView_SetScrollTime(_left_hwnd, 100); - const String& root_name = GetDesktopFolder().get_name(_create_info._root_shell_path, SHGDN_FORPARSING); - - _root._drive_type = DRIVE_UNKNOWN; - lstrcpy(_root._volname, root_name); // most of the time "Desktop" - _root._fs_flags = 0; - lstrcpy(_root._fs, TEXT("Desktop")); - -//@@ _root._entry->read_tree(shell_info._root_shell_path.get_folder(), info._shell_path, SORT_NAME/*_sortOrder*/); - -/*@todo - we should call read_tree() here to iterate through the hierarchy and open all folders from shell_info._root_shell_path to shell_info._shell_path - -> see FileChildWindow::FileChildWindow() -*/ - _root._entry = new ShellDirectory(GetDesktopFolder(), _create_info._root_shell_path, _hwnd); - _root._entry->read_directory(); - - /* already filled by ShellDirectory constructor - lstrcpy(_root._entry->_data.cFileName, TEXT("Desktop")); */ - - TV_ITEM tvItem; tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN; @@ -349,25 +344,10 @@ void ShellBrowserChild::OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv) { CONTEXT("ShellBrowserChild::OnTreeItemSelected()"); - ShellEntry* entry = (ShellEntry*)pnmtv->itemNew.lParam; - _last_sel = pnmtv->itemNew.hItem; + Entry* entry = (Entry*)pnmtv->itemNew.lParam; - if (entry->_etype == ET_SHELL) { - IShellFolder* folder; - - if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - folder = static_cast(entry)->_folder; - else - folder = entry->get_parent_folder(); - - if (!folder) { - assert(folder); - return; - } - - UpdateFolderView(folder); - } + jump_to(entry); } void ShellBrowserChild::UpdateFolderView(IShellFolder* folder) @@ -538,7 +518,19 @@ int ShellBrowserChild::Command(int id, int code) break;//@todo case ID_BROWSE_UP: - break;//@todo + if (_left_hwnd) { + //@@ not necessary in this simply case: jump_to(_cur_dir->_up); + + //@@ -> move into jump_to() + HTREEITEM hitem = TreeView_GetParent(_left_hwnd, _last_sel); + + if (hitem) + TreeView_SelectItem(_left_hwnd, hitem); // sends TVN_SELCHANGED notification + } else { + if (_cur_dir->_up) + jump_to(_cur_dir->_up); + } + break; default: return 1; @@ -564,10 +556,10 @@ HRESULT ShellBrowserChild::OnDefaultCommand(LPIDA pida) { CONTEXT("ShellBrowserChild::OnDefaultCommand()"); - if (pida->cidl>=1) { + if (pida->cidl >= 1) { if (_left_hwnd) { // explorer mode - if (_last_sel) { - ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel); + //@@if (_last_sel) { + ShellDirectory* parent = _cur_dir;//@@(ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel); if (parent) { try { @@ -586,7 +578,7 @@ HRESULT ShellBrowserChild::OnDefaultCommand(LPIDA pida) if (expand_folder(static_cast(entry))) return S_OK; } - } + //@@} } else { // no tree control if (MainFrame::OpenShellFolders(pida, _hWndFrame)) return S_OK; @@ -625,3 +617,56 @@ bool ShellBrowserChild::expand_folder(ShellDirectory* entry) return false; } + + +void ShellBrowserChild::jump_to(void* path) +{ + Entry* entry = NULL; + + //@@ + if (!_cur_dir) + _cur_dir = static_cast(_root._entry); + +/*@todo + we should call read_tree() here to iterate through the hierarchy and open all folders from shell_info._root_shell_path to shell_info._shell_path + _root._entry->read_tree(shell_info._root_shell_path.get_folder(), info._shell_path, SORT_NAME); + -> see FileChildWindow::FileChildWindow() +*/ + + if (_cur_dir) { + _cur_dir->smart_scan(); + + entry = _cur_dir->find_entry(path); + + if (entry) + jump_to(entry); + } + + //@@ work around as long as we don't iterate correctly through the ShellEntry tree + if (!entry) { + LPITEMIDLIST pidl = (LPITEMIDLIST)path; + UpdateFolderView(ShellFolder(pidl)); + } +} + +void ShellBrowserChild::jump_to(Entry* entry) +{ + if (entry->_etype == ET_SHELL) { + IShellFolder* folder; + ShellDirectory* se = static_cast(entry); + + if (se->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + folder = static_cast(se)->_folder; + else + folder = se->get_parent_folder(); + + if (!folder) { + assert(folder); + return; + } + + UpdateFolderView(folder); + + _cur_dir = se; + } +} diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.h b/reactos/subsys/system/explorer/shell/shellbrowser.h index 0dd5cd0d2d7..fe8aee48719 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.h +++ b/reactos/subsys/system/explorer/shell/shellbrowser.h @@ -144,5 +144,11 @@ public: int _last_split; RECT _clnt_rect; - void resize_children(); + /*virtual*/ void resize_children(); + /*virtual*/ void jump_to(void* path); + + void jump_to(Entry* entry); + +protected: + ShellDirectory* _cur_dir; };