LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_MBUTTONDBLCLK: explorer_show_frame(SW_SHOWNORMAL); break; case WM_DISPLAYCHANGE: MoveWindow(_hwnd, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE); MoveWindow(g_Globals._hwndShellView, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE); MoveWindow(_desktopBar, 0, HIWORD(lparam) - DESKTOPBARBAR_HEIGHT, LOWORD(lparam), DESKTOPBARBAR_HEIGHT, TRUE); break; case WM_GETISHELLBROWSER: return (LRESULT)static_cast<IShellBrowser*>(this); case WM_DESTROY: ///@todo use IShellBrowser::GetViewStateStream() and _pShellView->SaveViewState() to store view state if (SetShellWindow) SetShellWindow(0); break; case WM_CLOSE: ShowExitWindowsDialog(_hwnd); break; case WM_SYSCOMMAND: if (wparam == SC_TASKLIST) { if (_desktopBar) SendMessage(_desktopBar, nmsg, wparam, lparam); } goto def; case WM_SYSCOLORCHANGE: // redraw background window - it's done by system //InvalidateRect(g_Globals._hwndShellView, NULL, TRUE); // forward message to common controls SendMessage(g_Globals._hwndShellView, WM_SYSCOLORCHANGE, 0, 0); SendMessage(_desktopBar, WM_SYSCOLORCHANGE, 0, 0); break; default: def: return super::WndProc(nmsg, wparam, lparam); } return 0; }
LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_MBUTTONDBLCLK: explorer_show_frame(SW_SHOWNORMAL); break; case WM_DISPLAYCHANGE: MoveWindow(_hwnd, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE); MoveWindow(g_Globals._hwndShellView, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE); MoveWindow(_desktopBar, 0, HIWORD(lparam) - DESKTOPBARBAR_HEIGHT, LOWORD(lparam), DESKTOPBARBAR_HEIGHT, TRUE); break; case WM_GETISHELLBROWSER: return (LRESULT)static_cast<IShellBrowser*>(this); case WM_DESTROY: ///@todo use IShellBrowser::GetViewStateStream() and _pShellView->SaveViewState() to store view state if (SetShellWindow) SetShellWindow(0); break; case WM_CLOSE: ShowExitWindowsDialog(_hwnd); break; case WM_SYSCOMMAND: if (wparam == SC_TASKLIST) { if (_desktopBar) SendMessage(_desktopBar, nmsg, wparam, lparam); } goto def; case WM_SYSCOLORCHANGE: // redraw background window - it's done by system //InvalidateRect(g_Globals._hwndShellView, NULL, TRUE); // forward message to common controls SendMessage(g_Globals._hwndShellView, WM_SYSCOLORCHANGE, 0, 0); SendMessage(_desktopBar, WM_SYSCOLORCHANGE, 0, 0); break; case WM_SETTINGCHANGE: SendMessage(g_Globals._hwndShellView, nmsg, wparam, lparam); break; case PM_TRANSLATE_MSG: { /* TranslateAccelerator is called for all explorer windows that are open so we have to decide if this is the correct recipient */ LPMSG lpmsg = (LPMSG)lparam; HWND hwnd = lpmsg->hwnd; while(hwnd) { if(hwnd == _hwnd) break; hwnd = GetParent(hwnd); } if (hwnd) return _pShellView->TranslateAccelerator(lpmsg) == S_OK; return false; } default: def: return super::WndProc(nmsg, wparam, lparam); } return 0; }
LRESULT DesktopWindow::Init(LPCREATESTRUCT pcs) { if (super::Init(pcs)) return 1; HRESULT hr = GetDesktopFolder()->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView); /* also possible: SFV_CREATE sfv_create; sfv_create.cbSize = sizeof(SFV_CREATE); sfv_create.pshf = GetDesktopFolder(); sfv_create.psvOuter = NULL; sfv_create.psfvcb = NULL; HRESULT hr = SHCreateShellFolderView(&sfv_create, &_pShellView); */ HWND hWndView = 0; if (SUCCEEDED(hr)) { FOLDERSETTINGS fs; fs.ViewMode = FVM_ICON; fs.fFlags = FWF_DESKTOP|FWF_NOCLIENTEDGE|FWF_NOSCROLL|FWF_BESTFITWINDOW|FWF_SNAPTOGRID; //|FWF_AUTOARRANGE; ClientRect rect(_hwnd); hr = _pShellView->CreateViewWindow(NULL, &fs, this, &rect, &hWndView); ///@todo use IShellBrowser::GetViewStateStream() to restore previous view state -> see SHOpenRegStream() if (SUCCEEDED(hr)) { g_Globals._hwndShellView = hWndView; // subclass shellview window new DesktopShellView(hWndView, _pShellView); _pShellView->UIActivate(SVUIA_ACTIVATE_FOCUS); /* IShellView2* pShellView2; hr = _pShellView->QueryInterface(IID_IShellView2, (void**)&pShellView2); SV2CVW2_PARAMS params; params.cbSize = sizeof(SV2CVW2_PARAMS); params.psvPrev = _pShellView; params.pfs = &fs; params.psbOwner = this; params.prcView = ▭ params.pvid = params.pvid;//@@ hr = pShellView2->CreateViewWindow2(¶ms); params.pvid; */ /* IFolderView* pFolderView; hr = _pShellView->QueryInterface(IID_IFolderView, (void**)&pFolderView); if (SUCCEEDED(hr)) { hr = pFolderView->GetAutoArrange(); hr = pFolderView->SetCurrentViewMode(FVM_DETAILS); } */ } } if (hWndView && SetShellWindowEx) SetShellWindowEx(_hwnd, hWndView); else if (SetShellWindow) SetShellWindow(_hwnd); // create the explorer bar _desktopBar = DesktopBar::Create(); g_Globals._hwndDesktopBar = _desktopBar; return 0; }