diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index 4dbd5671c77..a2a2c1af9fe 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -32,6 +32,7 @@ static BOOL (WINAPI*SetShellWindow)(HWND); +static BOOL (WINAPI*SetShellWindowEx)(HWND, HWND); BOOL IsAnyDesktopRunning() @@ -39,6 +40,7 @@ BOOL IsAnyDesktopRunning() HINSTANCE shell32 = GetModuleHandle(TEXT("user32")); SetShellWindow = (BOOL(WINAPI*)(HWND)) GetProcAddress(shell32, "SetShellWindow"); + SetShellWindowEx = (BOOL(WINAPI*)(HWND,HWND)) GetProcAddress(shell32, "SetShellWindowEx"); return GetShellWindow() != 0; } @@ -48,16 +50,10 @@ DesktopWindow::DesktopWindow(HWND hwnd) : super(hwnd) { _pShellView = NULL; - - if (SetShellWindow) - SetShellWindow(hwnd); } DesktopWindow::~DesktopWindow() { - if (SetShellWindow) - SetShellWindow(0); - if (_pShellView) _pShellView->Release(); } @@ -102,6 +98,40 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) case WM_GETISHELLBROWSER: return (LRESULT)static_cast(this); + case WM_CREATE: { + HRESULT hr = Desktop()->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView); + + HWND hWndListView = 0; + + if (SUCCEEDED(hr)) { + FOLDERSETTINGS fs; + + fs.ViewMode = FWF_DESKTOP|FWF_TRANSPARENT|FWF_NOSUBFOLDERS|FWF_BESTFITWINDOW|FWF_ABBREVIATEDNAMES; + fs.fFlags = FVM_ICON; + + RECT rect; + GetClientRect(_hwnd, &rect); + + hr = _pShellView->CreateViewWindow(NULL, &fs, this, &rect, &hWndListView); + + if (SUCCEEDED(hr)) { + HWND hwndFolderView = ::GetNextWindow(hWndListView, GW_CHILD); + + ShowWindow(hwndFolderView, SW_SHOW); + } + } + + if (hWndListView && SetShellWindowEx) + SetShellWindowEx(_hwnd, hWndListView); + else if (SetShellWindow) + SetShellWindow(_hwnd); + break;} + + case WM_DESTROY: + if (SetShellWindow) + SetShellWindow(0); + break; + case WM_CLOSE: break; // Over-ride close. We need to close desktop some other way. @@ -128,39 +158,7 @@ HWND create_desktop_window(HINSTANCE hInstance) int width = GetSystemMetrics(SM_CXSCREEN); int height = GetSystemMetrics(SM_CYSCREEN); - HWND hwndDesktop = Window::Create(WINDOW_CREATOR(DesktopWindow), - 0, (LPCTSTR)desktopClass, _T("Progman"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, + return Window::Create(WINDOW_CREATOR(DesktopWindow), + 0, (LPCTSTR)(int)desktopClass, _T("Progman"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN, 0, 0, width, height, 0); - - if (!hwndDesktop) - return 0; - - - ShellFolder folder; - - IShellView* pShellView; - HRESULT hr = folder->CreateViewObject(hwndDesktop, IID_IShellView, (void**)&pShellView); - - HWND hWndListView = 0; - - if (SUCCEEDED(hr)) { - FOLDERSETTINGS fs; - - fs.ViewMode = 0; - fs.fFlags = FVM_ICON; - - RECT rect = {0, 0, width, height}; - - DesktopWindow* shell_browser = static_cast(Window::get_window(hwndDesktop)); - - hr = pShellView->CreateViewWindow(NULL, &fs, shell_browser, &rect, &hWndListView); - - if (SUCCEEDED(hr)) { - HWND hwndFolderView = GetNextWindow(hWndListView, GW_CHILD); - - ShowWindow(hwndFolderView, SW_SHOW); - } - } - - return hwndDesktop; } diff --git a/reactos/subsys/system/explorer/desktop/desktop.h b/reactos/subsys/system/explorer/desktop/desktop.h index 0ec1fb39af5..bafb68e638d 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.h +++ b/reactos/subsys/system/explorer/desktop/desktop.h @@ -38,9 +38,8 @@ struct DesktopWindow : public Window, public IShellBrowserImpl { typedef Window super; - DesktopWindow::DesktopWindow(HWND hwnd); - - DesktopWindow::~DesktopWindow(); + DesktopWindow(HWND hwnd); + ~DesktopWindow(); STDMETHOD(GetWindow)(HWND* lphwnd) { @@ -48,14 +47,14 @@ struct DesktopWindow : public Window, public IShellBrowserImpl return S_OK; } - STDMETHOD(QueryActiveShellView)(struct IShellView ** ppshv) + STDMETHOD(QueryActiveShellView)(IShellView** ppshv) { _pShellView->AddRef(); *ppshv = _pShellView; return S_OK; } - STDMETHOD(GetControlWindow)(UINT id, HWND * lphwnd) + STDMETHOD(GetControlWindow)(UINT id, HWND* lphwnd) { return E_NOTIMPL; } diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index a169ccd0b49..615e3f1fcd5 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -359,8 +359,8 @@ void ShellBrowserChild::OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv) if (pLastShellView) pLastShellView->GetCurrentInfo(&fs); else { - fs.fFlags = FVM_DETAILS; fs.ViewMode = FWF_SNAPTOGRID; + fs.fFlags = FVM_DETAILS; } HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView); diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.h b/reactos/subsys/system/explorer/shell/shellbrowser.h index e3fc7a13e51..d43339ef58e 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.h +++ b/reactos/subsys/system/explorer/shell/shellbrowser.h @@ -57,14 +57,14 @@ struct ShellBrowserChild : public ChildWindow, public IShellBrowserImpl } //IShellBrowser - STDMETHOD(QueryActiveShellView)(struct IShellView ** ppshv) + STDMETHOD(QueryActiveShellView)(IShellView** ppshv) { _pShellView->AddRef(); *ppshv = _pShellView; return S_OK; } - STDMETHOD(GetControlWindow)(UINT id, HWND * lphwnd) + STDMETHOD(GetControlWindow)(UINT id, HWND* lphwnd) { if (!lphwnd) return E_POINTER;