Add support for explorer to load the desk.cpl when right clicking on background.
[reactos.git] / reactos / subsys / system / explorer / desktop / desktop.cpp
index 75bb0ed..41b08b2 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
@@ -278,6 +278,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,27 +300,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;
-
-       #include "../buildno.h"
-               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);
-       }
 }
 
 
@@ -481,7 +462,7 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
 
 HRESULT DesktopWindow::OnDefaultCommand(LPIDA pida)
 {
-       if (MainFrame::OpenShellFolders(pida, 0))
+       if (MainFrameBase::OpenShellFolders(pida, 0))
                return S_OK;
 
        return E_NOTIMPL;
@@ -541,11 +522,11 @@ 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:
-               if (!DoContextMenu(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)))
+               if (!DoContextMenu(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), _cm_ifs))
                        DoDesktopContextMenu(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
                break;
 
@@ -577,7 +558,7 @@ int DesktopShellView::Notify(int id, NMHDR* pnmh)
        return super::Notify(id, pnmh);
 }
 
-bool DesktopShellView::DoContextMenu(int x, int y)
+bool DesktopShellView::DoContextMenu(int x, int y, CtxMenuInterfaces& cm_ifs)
 {
        IDataObject* selection;
 
@@ -607,7 +588,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();
 
@@ -623,17 +604,40 @@ 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) {
                        hr = pcm->QueryContextMenu(hmenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST-1, CMF_NORMAL|CMF_EXPLORE);
 
                        if (SUCCEEDED(hr)) {
+                               AppendMenu(hmenu, 0, FCIDM_SHVIEWLAST-3, ResString(IDS_PROPERTIES_EXPLORER));
                                AppendMenu(hmenu, MF_SEPARATOR, 0, NULL);
                                AppendMenu(hmenu, 0, FCIDM_SHVIEWLAST-1, ResString(IDS_ABOUT_EXPLORER));
 
                                UINT idCmd = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON, x, y, 0, _hwnd, NULL);
 
+                               _cm_ifs.reset();
+
+                               if (idCmd == FCIDM_SHVIEWLAST-3) {
+                                       ShellExecute (_hwnd, _T("open"), _T("c:\\reactos\\system32\\rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0"), NULL, NULL, SW_SHOWNORMAL);
+
+
+                                       //explorer_about(_hwnd);
+                                       //system("c:\\reactos\\system32\\cmd.exe");
+                                       
+                                       //ShellExecute (_hwnd, _T("open"), _T("%SystemRoot%\\system32\\cmd.exe"), NULL, NULL, SW_SHOWNORMAL);
+                                       
+                                         //ShellExecute(NULL,"open","c:\\windows\\system32\\cmd.exe",NULL,NULL,SW_SHOWNORMAL);
+                                       //WCHAR* pFile="%SystemRoot%\system32\cmd.exe";
+                                       //int rcode;
+                                        //TCHAR pFile[256];
+                                        //strcopy("%SystemRoot%\\system32\\cmd.exe",pFile);
+                                        //ShellExecute(NULL, NULL, pFile, NULL, "C:\\", SW_SHOW);
+                                       //HINSTANCE rcode=ShellExecute(NULL, "open", pFile, NULL, "C:\\", SW_SHOW);
+                                       //ShellExecute(hwnd, __TEXT("open"), __TEXT("%SystemRoot%\system32\cmd.exe"), __TEXT("c:\"), SH_SHOW); 
+                               }
                                if (idCmd == FCIDM_SHVIEWLAST-1) {
                                        explorer_about(_hwnd);
                                } else if (idCmd) {