From 16fd2633a60490828eb65a07d69e8bdb06f776f6 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 12 Oct 2007 14:25:58 +0000 Subject: [PATCH] - explictely use PROPSHEETHEADERW - implement _ILIsBitBucket function - implement a IContextMenu for recycle bin interface but is currently unused see notes shv_item_cmenu.c - implement recycle property dialog resources in vista style svn path=/trunk/; revision=29537 --- reactos/dll/win32/shell32/drive.c | 4 +- reactos/dll/win32/shell32/fprop.c | 11 +- reactos/dll/win32/shell32/pidl.c | 10 + reactos/dll/win32/shell32/pidl.h | 1 + reactos/dll/win32/shell32/recyclebin.c | 218 ++++++++++++++++++++- reactos/dll/win32/shell32/shell32_De.rc | 13 ++ reactos/dll/win32/shell32/shell32_En.rc | 13 ++ reactos/dll/win32/shell32/shell32_main.h | 3 +- reactos/dll/win32/shell32/shres.rc | 1 - reactos/dll/win32/shell32/shv_item_cmenu.c | 13 ++ 10 files changed, 279 insertions(+), 8 deletions(-) diff --git a/reactos/dll/win32/shell32/drive.c b/reactos/dll/win32/shell32/drive.c index e2dda831f31..8c24981aaf8 100644 --- a/reactos/dll/win32/shell32/drive.c +++ b/reactos/dll/win32/shell32/drive.c @@ -411,8 +411,8 @@ SH_ShowDriveProperties(WCHAR * drive) BOOL ret; UINT i; - ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); - psh.dwSize = sizeof(PROPSHEETHEADER); + ZeroMemory(&psh, sizeof(PROPSHEETHEADERW)); + psh.dwSize = sizeof(PROPSHEETHEADERW); //psh.dwFlags = PSH_USECALLBACK | PSH_PROPTITLE; psh.hwndParent = NULL; psh.nStartPage = 0; diff --git a/reactos/dll/win32/shell32/fprop.c b/reactos/dll/win32/shell32/fprop.c index 69ef8ecbbfa..c414c4384ff 100644 --- a/reactos/dll/win32/shell32/fprop.c +++ b/reactos/dll/win32/shell32/fprop.c @@ -62,7 +62,7 @@ typedef struct _LANGANDCODEPAGE_ * */ HPROPSHEETPAGE -SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam) +SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle) { HRSRC hRes; LPVOID lpsztemplate; @@ -88,6 +88,11 @@ SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam) ppage.u.pResource = lpsztemplate; ppage.pfnDlgProc = dlgproc; ppage.lParam = lParam; + ppage.pszTitle = szTitle; + if (szTitle) + { + ppage.dwFlags |= PSP_USETITLE; + } return CreatePropertySheetPageW(&ppage); } @@ -645,7 +650,7 @@ SH_ShowPropertiesDialog(WCHAR * lpf) FIXME("directory / drive resources are missing\n"); return FALSE; } - hpage = SH_CreatePropertySheetPage("SHELL_FILE_GENERAL_DLG", SH_FileGeneralDlgProc, (LPARAM)wFileName); + hpage = SH_CreatePropertySheetPage("SHELL_FILE_GENERAL_DLG", SH_FileGeneralDlgProc, (LPARAM)wFileName, NULL); if (hpage == NULL) return FALSE; @@ -654,7 +659,7 @@ SH_ShowPropertiesDialog(WCHAR * lpf) num_pages++; if ( GetFileVersionInfoSizeW(lpf, &dwHandle) ) { - if ( (hpage = SH_CreatePropertySheetPage("SHELL_FILE_VERSION_DLG",SH_FileVersionDlgProc, (LPARAM)lpf))!= NULL) + if ( (hpage = SH_CreatePropertySheetPage("SHELL_FILE_VERSION_DLG",SH_FileVersionDlgProc, (LPARAM)lpf, NULL))!= NULL) { hppages[num_pages] = hpage; num_pages++; diff --git a/reactos/dll/win32/shell32/pidl.c b/reactos/dll/win32/shell32/pidl.c index bf15e055722..cd7a984f957 100644 --- a/reactos/dll/win32/shell32/pidl.c +++ b/reactos/dll/win32/shell32/pidl.c @@ -1633,6 +1633,16 @@ BOOL _ILIsMyComputer(LPCITEMIDLIST pidl) return IsEqualIID(iid, &CLSID_MyComputer); return FALSE; } +BOOL _ILIsBitBucket(LPCITEMIDLIST pidl) +{ + REFIID iid = _ILGetGUIDPointer(pidl); + + TRACE("(%p)\n",pidl); + + if (iid) + return IsEqualIID(iid, &CLSID_RecycleBin); + return FALSE; +} BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl) { diff --git a/reactos/dll/win32/shell32/pidl.h b/reactos/dll/win32/shell32/pidl.h index 010947c19cb..e1f89d9e7b3 100644 --- a/reactos/dll/win32/shell32/pidl.h +++ b/reactos/dll/win32/shell32/pidl.h @@ -204,6 +204,7 @@ DWORD _ILGetDrive (LPCITEMIDLIST, LPSTR, UINT); BOOL _ILIsUnicode (LPCITEMIDLIST pidl); BOOL _ILIsDesktop (LPCITEMIDLIST pidl); BOOL _ILIsMyComputer (LPCITEMIDLIST pidl); +BOOL _ILIsBitBucket (LPCITEMIDLIST pidl); BOOL _ILIsDrive (LPCITEMIDLIST pidl); BOOL _ILIsFolder (LPCITEMIDLIST pidl); BOOL _ILIsValue (LPCITEMIDLIST pidl); diff --git a/reactos/dll/win32/shell32/recyclebin.c b/reactos/dll/win32/shell32/recyclebin.c index ec6f724fbfa..91ff233d869 100644 --- a/reactos/dll/win32/shell32/recyclebin.c +++ b/reactos/dll/win32/shell32/recyclebin.c @@ -22,6 +22,8 @@ #define YDEBUG #define COBJMACROS #define NONAMELESSUNION +#define NONAMELESSSTRUCT +#define MAX_PROPERTY_SHEET_PAGE 32 #include @@ -40,6 +42,7 @@ #include "enumidlist.h" #include "xdg.h" #include "recyclebin.h" +#include WINE_DEFAULT_DEBUG_CHANNEL(recyclebin); @@ -102,14 +105,25 @@ typedef struct tagRecycleBin { const IShellFolder2Vtbl *lpVtbl; const IPersistFolder2Vtbl *lpPersistFolderVtbl; + const IContextMenuVtbl *lpCmt; LONG refCount; + INT iIdOpen; + INT iIdEmpty; + INT iIdProperties; + LPITEMIDLIST pidl; } RecycleBin; +static const IContextMenuVtbl recycleBincmVtbl; static const IShellFolder2Vtbl recycleBinVtbl; static const IPersistFolder2Vtbl recycleBinPersistVtbl; +static RecycleBin *impl_from_IContextMenu(IContextMenu *iface) +{ + return (RecycleBin *)((char *)iface - FIELD_OFFSET(RecycleBin, lpCmt)); +} + static RecycleBin *impl_from_IPersistFolder(IPersistFolder2 *iface) { return (RecycleBin *)((char *)iface - FIELD_OFFSET(RecycleBin, lpPersistFolderVtbl)); @@ -130,6 +144,7 @@ HRESULT WINAPI RecycleBin_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID * ZeroMemory(obj, sizeof(RecycleBin)); obj->lpVtbl = &recycleBinVtbl; obj->lpPersistFolderVtbl = &recycleBinPersistVtbl; + obj->lpCmt = &recycleBincmVtbl; if (FAILED(ret = IUnknown_QueryInterface((IUnknown *)obj, riid, ppOutput))) { RecycleBin_Destructor(obj); @@ -160,6 +175,9 @@ static HRESULT WINAPI RecycleBin_QueryInterface(IShellFolder2 *iface, REFIID rii || IsEqualGUID(riid, &IID_IPersistFolder2)) *ppvObject = &This->lpPersistFolderVtbl; + if (IsEqualGUID(riid, &IID_IContextMenu)) + *ppvObject = &This->lpCmt; + if (*ppvObject != NULL) { IUnknown_AddRef((IUnknown *)*ppvObject); @@ -246,7 +264,7 @@ CBEnumBitBucket(IN PVOID Context, IN HANDLE hDeletedFile) } PDELETED_FILE_DETAILS_W -UnpackDetailsFromPidl(LPITEMIDLIST pidl) +UnpackDetailsFromPidl(LPCITEMIDLIST pidl) { return (PDELETED_FILE_DETAILS_W)&pidl->mkid.abID[1]; } @@ -568,3 +586,201 @@ HRESULT WINAPI SHUpdateRecycleBinIcon(void) FIXME("stub\n"); return S_OK; } +static HRESULT WINAPI +RecycleBin_IContextMenu_QueryInterface( IContextMenu* iface, REFIID riid, void** ppvObject ) +{ + return RecycleBin_QueryInterface((IShellFolder2 *)impl_from_IContextMenu(iface), riid, ppvObject); +} + +static ULONG WINAPI +RecycleBin_IContextMenu_AddRef( IContextMenu* iface ) +{ + return RecycleBin_AddRef((IShellFolder2 *)impl_from_IContextMenu(iface)); +} + +static ULONG WINAPI +RecycleBin_IContextMenu_Release( IContextMenu* iface ) +{ + return RecycleBin_Release((IShellFolder2 *)impl_from_IContextMenu(iface)); +} + +static HRESULT WINAPI +RecycleBin_IContextMenu_QueryContextMenu( IContextMenu* iface, HMENU hmenu, UINT indexMenu, + UINT idCmdFirst, UINT idCmdLast, UINT uFlags ) +{ + RecycleBin * This = impl_from_IContextMenu(iface); + static WCHAR szOpen[] = { 'O','p','e','n',0 }; + static WCHAR szEmpty[] = { 'E','m','p','t','y',' ','R','e','c','y','c','l','e',' ','B','i','n',0 }; + static WCHAR szProperties[] = { 'P','r','o','p','e','r','t','i','e','s',0 }; + MENUITEMINFOW mii; + int id = 1; + + TRACE("%p %p %u %u %u %u\n", This, + hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags ); + + if ( !hmenu ) + return E_INVALIDARG; + + memset( &mii, 0, sizeof(mii) ); + mii.cbSize = sizeof (mii); + mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; + mii.dwTypeData = (LPWSTR)szOpen; + mii.cch = strlenW( mii.dwTypeData ); + mii.wID = idCmdFirst + id++; + mii.fState = MFS_ENABLED; + mii.fType = MFT_STRING; + if (!InsertMenuItemW( hmenu, indexMenu, TRUE, &mii )) + return E_FAIL; + This->iIdOpen = 0; + + mii.fState = MFS_ENABLED; + mii.dwTypeData = (LPWSTR)szEmpty; + mii.cch = strlenW( mii.dwTypeData ); + mii.wID = idCmdFirst + id++; + if (!InsertMenuItemW( hmenu, idCmdLast, TRUE, &mii )) + { + TRACE("RecycleBin_IContextMenu_QueryContextMenu failed to insert item properties"); + return E_FAIL; + } + This->iIdEmpty = 1; + id++; + + mii.fState = MFS_ENABLED; + mii.dwTypeData = (LPWSTR)szProperties; + mii.cch = strlenW( mii.dwTypeData ); + mii.wID = idCmdFirst + id++; + if (!InsertMenuItemW( hmenu, idCmdLast, TRUE, &mii )) + { + TRACE("RecycleBin_IContextMenu_QueryContextMenu failed to insert item properties"); + return E_FAIL; + } + This->iIdProperties = 2; + id++; + + return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id ); +} + +static HRESULT WINAPI +RecycleBin_IContextMenu_InvokeCommand( IContextMenu* iface, LPCMINVOKECOMMANDINFO lpici ) +{ + RecycleBin * This = impl_from_IContextMenu(iface); + + TRACE("%p %p\n", This, lpici ); + + return E_FAIL; +} + +static HRESULT WINAPI +RecycleBin_IContextMenu_GetCommandString( IContextMenu* iface, UINT_PTR idCmd, UINT uType, + UINT* pwReserved, LPSTR pszName, UINT cchMax ) +{ + RecycleBin * This = impl_from_IContextMenu(iface); + + FIXME("%p %lu %u %p %p %u\n", This, + idCmd, uType, pwReserved, pszName, cchMax ); + + return E_NOTIMPL; +} + +static const IContextMenuVtbl recycleBincmVtbl = +{ + RecycleBin_IContextMenu_QueryInterface, + RecycleBin_IContextMenu_AddRef, + RecycleBin_IContextMenu_Release, + RecycleBin_IContextMenu_QueryContextMenu, + RecycleBin_IContextMenu_InvokeCommand, + RecycleBin_IContextMenu_GetCommandString +}; + +INT_PTR +CALLBACK +RecycleBinGeneralDlg( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + + + return FALSE; +} + +void +InitializeBitBucketDlg(HWND hwndDlg) +{ + WCHAR CurDrive = L'A'; + WCHAR szDrive[] = L"A:\\"; + DWORD dwDrives; + WCHAR szName[MAX_PATH+1]; + DWORD MaxComponent, Flags; + + dwDrives = GetLogicalDrives(); + do + { + if ((dwDrives & 0x1)) + { + UINT Type = GetDriveTypeW(szDrive); + if (Type == DRIVE_FIXED) //FIXME + { + if (!GetVolumeInformationW(szDrive, szName, MAX_PATH+1, NULL, &MaxComponent, &Flags, NULL, 0)) + { + wcscpy(szName, szDrive); + } + } + } + CurDrive++; + szDrive[0] = CurDrive; + dwDrives = (dwDrives >> 1); + }while(dwDrives); + + +} + + + +INT_PTR +CALLBACK +BitBucketDlg( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + + + return FALSE; +} + +BOOL SH_ShowRecycleBinProperties(WCHAR sDrive) +{ + HPROPSHEETPAGE hpsp[1]; + PROPSHEETHEADERW psh; + HPROPSHEETPAGE hprop; + + BOOL ret; + + + ZeroMemory(&psh, sizeof(PROPSHEETHEADERW)); + psh.dwSize = sizeof(PROPSHEETHEADERW); + psh.hwndParent = NULL; + psh.u3.phpage = hpsp; + + hprop = SH_CreatePropertySheetPage("BITBUCKET_PROPERTIES_DLG", BitBucketDlg, (LPARAM)0, NULL); + if (!hprop) + { + ERR("Failed to create property sheet"); + return FALSE; + } + hpsp[psh.nPages] = hprop; + psh.nPages++; + + + ret = PropertySheetW(&psh); + if (ret < 0) + return FALSE; + else + return TRUE; +} + diff --git a/reactos/dll/win32/shell32/shell32_De.rc b/reactos/dll/win32/shell32/shell32_De.rc index 52b177f38cd..48cb1ac7662 100644 --- a/reactos/dll/win32/shell32/shell32_De.rc +++ b/reactos/dll/win32/shell32/shell32_De.rc @@ -327,6 +327,19 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 PUSHBUTTON "Abbrechen", 14008, 140, 170, 60, 15, WS_TABSTOP } +BITBUCKET_PROPERTIES_DLG DIALOGEX 0, 0, 240, 190 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Recycle Bin Properties" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +{ + CONTROL "", -1, "SysListView32", LVS_REPORT | LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP, 10, 10, 220, 50 + GROUPBOX "Settings for selected location", -1, 10, 80, 220, 70 + RADIOBUTTON "&Custom size:", -1, 20, 90, 80, 10 + EDITTEXT -1, 90, 90, 50, 10, WS_TABSTOP + LTEXT "M&aximum size(MB):", -1, 20, 100, 70, 10 + RADIOBUTTON "Do not move files to the &Recycle Bin. Remove files immediately when deleted.", -1, 20, 115, 170, 20, BS_MULTILINE | WS_TABSTOP + RADIOBUTTON"&Display delete confirmation dialog", -1, 20, 155, 140, 10, WS_TABSTOP +} STRINGTABLE DISCARDABLE { diff --git a/reactos/dll/win32/shell32/shell32_En.rc b/reactos/dll/win32/shell32/shell32_En.rc index 77f97033f02..b86e8f37467 100644 --- a/reactos/dll/win32/shell32/shell32_En.rc +++ b/reactos/dll/win32/shell32/shell32_En.rc @@ -327,6 +327,19 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 PUSHBUTTON "Cancel", 14008, 140, 170, 60, 15, WS_TABSTOP } +BITBUCKET_PROPERTIES_DLG DIALOGEX 0, 0, 240, 190 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Recycle Bin Properties" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +{ + CONTROL "", -1, "SysListView32", LVS_REPORT | LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP, 10, 10, 220, 50 + GROUPBOX "Settings for selected location", -1, 10, 80, 220, 70 + RADIOBUTTON "&Custom size:", -1, 20, 90, 80, 10 + EDITTEXT -1, 90, 90, 50, 10, WS_TABSTOP + LTEXT "M&aximum size(MB):", -1, 20, 100, 70, 10 + RADIOBUTTON "Do not move files to the &Recycle Bin. Remove files immediately when deleted.", -1, 20, 115, 170, 20, BS_MULTILINE | WS_TABSTOP + RADIOBUTTON"&Display delete confirmation dialog", -1, 20, 155, 140, 10, WS_TABSTOP +} STRINGTABLE DISCARDABLE { diff --git a/reactos/dll/win32/shell32/shell32_main.h b/reactos/dll/win32/shell32/shell32_main.h index 45405847d8d..08a9da0f251 100644 --- a/reactos/dll/win32/shell32/shell32_main.h +++ b/reactos/dll/win32/shell32/shell32_main.h @@ -241,6 +241,7 @@ BOOL SHELL_IsShortcut(LPCITEMIDLIST); INT_PTR CALLBACK SH_FileGeneralDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK SH_FileVersionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -HPROPSHEETPAGE SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam); +HPROPSHEETPAGE SH_CreatePropertySheetPage(LPSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle); BOOL SH_ShowDriveProperties(WCHAR * drive); +BOOL SH_ShowRecycleBinProperties(WCHAR sDrive); #endif diff --git a/reactos/dll/win32/shell32/shres.rc b/reactos/dll/win32/shell32/shres.rc index 4bc36e99140..e62b95f810f 100644 --- a/reactos/dll/win32/shell32/shres.rc +++ b/reactos/dll/win32/shell32/shres.rc @@ -36,7 +36,6 @@ BEGIN END - /* * Everything that does not depend on language, * like textless bitmaps etc, go into the diff --git a/reactos/dll/win32/shell32/shv_item_cmenu.c b/reactos/dll/win32/shell32/shv_item_cmenu.c index 5dc5fc23a2b..cc06851154d 100644 --- a/reactos/dll/win32/shell32/shv_item_cmenu.c +++ b/reactos/dll/win32/shell32/shv_item_cmenu.c @@ -396,6 +396,13 @@ static void DoProperties( LPITEMIDLIST pidlFQ = NULL; SHELLEXECUTEINFOA sei; + /* + * FIXXME + * + * The IShellFolder interface GetUIObject should create the specific item and then query if it has an IContextMenu interface + * If yes return interface to it. + */ + if (_ILIsMyComputer(This->apidl[0])) { ShellExecuteA(hwnd, "open", "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl", NULL, NULL, SW_SHOWNORMAL); @@ -413,6 +420,12 @@ static void DoProperties( SH_ShowDriveProperties(buffer); return; } + else if (_ILIsBitBucket(This->apidl[0])) + { + ///FIXME + WCHAR szDrive = 'C'; + SH_ShowRecycleBinProperties(szDrive); + } else { pidlFQ = ILCombine(This->pidl, This->apidl[0]);