merge ROS Shell without integrated explorer part into trunk
[reactos.git] / reactos / subsys / system / explorer / desktop / desktop.cpp
index 178db37..21ecd83 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003, 2004 Martin Fuchs
+ * Copyright 2003, 2004, 2005 Martin Fuchs
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -155,8 +155,8 @@ static BOOL CALLBACK SwitchDesktopEnumFct(HWND hwnd, LPARAM lparam)
 {
        WindowSet& windows = *(WindowSet*)lparam;
 
-       if (IsWindowVisible(hwnd))
-               if (hwnd!=g_Globals._hwndDesktopBar && hwnd!=g_Globals._hwndDesktop)
+       if (hwnd!=g_Globals._hwndDesktopBar && hwnd!=g_Globals._hwndDesktop)
+               if (IsWindowVisible(hwnd))
                        windows.insert(hwnd);
 
        return TRUE;
@@ -212,12 +212,17 @@ static BOOL CALLBACK MinimizeDesktopEnumFct(HWND hwnd, LPARAM lparam)
 {
        list<MinimizeStruct>& minimized = *(list<MinimizeStruct>*)lparam;
 
-       if (IsWindowVisible(hwnd))
-               if (hwnd!=g_Globals._hwndDesktopBar && hwnd!=g_Globals._hwndDesktop)
-                       if (!IsIconic(hwnd)) {
+       if (hwnd!=g_Globals._hwndDesktopBar && hwnd!=g_Globals._hwndDesktop)
+               if (IsWindowVisible(hwnd) && !IsIconic(hwnd)) {
+                       RECT rect;
+
+                       if (GetWindowRect(hwnd,&rect))
+                               if (rect.right>0 && rect.bottom>0 &&
+                                       rect.right>rect.left && rect.bottom>rect.top) {
                                minimized.push_back(MinimizeStruct(hwnd, GetWindowStyle(hwnd)));
                                ShowWindowAsync(hwnd, SW_MINIMIZE);
                        }
+               }
 
        return TRUE;
 }
@@ -278,6 +283,8 @@ LRESULT BackgroundWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
                        DWORD reset_mask = LOWORD(lparam);
                        DWORD xor_mask = HIWORD(lparam);
                        _display_version = ((_display_version&~reset_mask) | or_mask) ^ xor_mask;
+                       RegSetDWORDValue(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), TEXT("PaintDesktopVersion"), _display_version);
+                       ///@todo Changing the PaintDesktopVersion-Flag needs a restart of the shell -> display a message box
                        InvalidateRect(_hwnd, NULL, TRUE);
                }
                return _display_version;
@@ -298,31 +305,6 @@ void BackgroundWindow::DrawDesktopBkgnd(HDC hdc)
        FillRect(hdc, &rect, bkgndBrush);
        DeleteBrush(bkgndBrush);
 */
-       if (_display_version) {
-               ClientRect rect(_hwnd);
-
-               rect.left = rect.right - 280;
-               rect.top = rect.bottom - 56 - DESKTOPBARBAR_HEIGHT;
-               rect.right = rect.left + 250;
-               rect.bottom = rect.top + 40;
-
-#ifdef _ROS_
-#include <reactos/buildno.h>
-#else
-#include "../buildno.h"
-#endif
-               static const LPCTSTR BkgndText = TEXT("ReactOS ")TEXT(KERNEL_VERSION_STR)TEXT(" Explorer\nby Martin Fuchs");
-
-               BkMode bkMode(hdc, TRANSPARENT);
-
-               TextColor textColor(hdc, RGB(128,128,192));
-               DrawText(hdc, BkgndText, -1, &rect, DT_RIGHT);
-
-               SetTextColor(hdc, RGB(255,255,255));
-               --rect.right;
-               ++rect.top;
-               DrawText(hdc, BkgndText, -1, &rect, DT_RIGHT);
-       }
 }
 
 
@@ -459,7 +441,7 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
          case WM_DESTROY:
 
                ///@todo use IShellBrowser::GetViewStateStream() and _pShellView->SaveViewState() to store view state
-               
+
                if (SetShellWindow)
                        SetShellWindow(0);
                break;
@@ -485,8 +467,10 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
 
 HRESULT DesktopWindow::OnDefaultCommand(LPIDA pida)
 {
+#ifndef ROSSHELL       // in shell-only-mode fall through and let shell32 handle the command
        if (MainFrameBase::OpenShellFolders(pida, 0))
                return S_OK;
+#endif
 
        return E_NOTIMPL;
 }
@@ -545,7 +529,7 @@ bool DesktopShellView::InitDragDrop()
        return true;
 }
 
-LRESULT        DesktopShellView::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
+LRESULT DesktopShellView::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
 {
        switch(nmsg) {
          case WM_CONTEXTMENU:
@@ -611,7 +595,7 @@ bool DesktopShellView::DoContextMenu(int x, int y)
        for(int i=pida->cidl; i>0; --i)
                apidl[i-1] = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]);
 
-       hr = ShellFolderContextMenu(ShellFolder(parent_pidl), _hwnd, pida->cidl, apidl, x, y);
+       hr = ShellFolderContextMenu(ShellFolder(parent_pidl), _hwnd, pida->cidl, apidl, x, y, _cm_ifs);
 
        selection->Release();
 
@@ -627,6 +611,8 @@ HRESULT DesktopShellView::DoDesktopContextMenu(int x, int y)
        HRESULT hr = DesktopFolder()->GetUIObjectOf(_hwnd, 0, NULL, IID_IContextMenu, NULL, (LPVOID*)&pcm);
 
        if (SUCCEEDED(hr)) {
+               pcm = _cm_ifs.query_interfaces(pcm);
+
                HMENU hmenu = CreatePopupMenu();
 
                if (hmenu) {
@@ -638,6 +624,8 @@ HRESULT DesktopShellView::DoDesktopContextMenu(int x, int y)
 
                                UINT idCmd = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON, x, y, 0, _hwnd, NULL);
 
+                               _cm_ifs.reset();
+
                                if (idCmd == FCIDM_SHVIEWLAST-1) {
                                        explorer_about(_hwnd);
                                } else if (idCmd) {