2 * IContextMenu for items in the shellview
4 * Copyright 1998-2000 Juergen Schmied <juergen.schmied@debitel.net>,
5 * <juergen.schmied@metronet.de>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define NONAMELESSUNION
28 #include "wine/debug.h"
33 #include "undocshell.h"
38 #include "shell32_main.h"
39 #include "shellfolder.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
47 IContextMenu3 IContextMenu3_iface
;
53 LPITEMIDLIST pidl
; /* root pidl */
54 LPITEMIDLIST
*apidl
; /* array of child pidls */
58 /* background menu data */
62 static inline ContextMenu
*impl_from_IContextMenu3(IContextMenu3
*iface
)
64 return CONTAINING_RECORD(iface
, ContextMenu
, IContextMenu3_iface
);
67 static HRESULT WINAPI
ContextMenu_QueryInterface(IContextMenu3
*iface
, REFIID riid
, LPVOID
*ppvObj
)
69 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
71 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObj
);
75 if (IsEqualIID(riid
, &IID_IUnknown
) ||
76 IsEqualIID(riid
, &IID_IContextMenu
) ||
77 IsEqualIID(riid
, &IID_IContextMenu2
) ||
78 IsEqualIID(riid
, &IID_IContextMenu3
))
80 *ppvObj
= &This
->IContextMenu3_iface
;
82 else if (IsEqualIID(riid
, &IID_IShellExtInit
)) /*IShellExtInit*/
84 FIXME("-- LPSHELLEXTINIT pointer requested\n");
89 IContextMenu3_AddRef(iface
);
93 TRACE("-- Interface: E_NOINTERFACE\n");
97 static ULONG WINAPI
ContextMenu_AddRef(IContextMenu3
*iface
)
99 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
100 ULONG ref
= InterlockedIncrement(&This
->ref
);
101 TRACE("(%p)->(%u)\n", This
, ref
);
105 static ULONG WINAPI
ContextMenu_Release(IContextMenu3
*iface
)
107 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
108 ULONG ref
= InterlockedDecrement(&This
->ref
);
110 TRACE("(%p)->(%u)\n", This
, ref
);
115 IShellFolder_Release(This
->parent
);
118 _ILFreeaPidl(This
->apidl
, This
->cidl
);
120 HeapFree(GetProcessHeap(), 0, This
);
126 static HRESULT WINAPI
ItemMenu_QueryContextMenu(
127 IContextMenu3
*iface
,
134 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
137 TRACE("(%p)->(%p %d 0x%x 0x%x 0x%x )\n", This
, hmenu
, indexMenu
, idCmdFirst
, idCmdLast
, uFlags
);
139 if(!(CMF_DEFAULTONLY
& uFlags
) && This
->cidl
> 0)
141 HMENU hmenures
= LoadMenuW(shell32_hInstance
, MAKEINTRESOURCEW(MENU_SHV_FILE
));
143 if(uFlags
& CMF_EXPLORE
)
144 RemoveMenu(hmenures
, FCIDM_SHVIEW_OPEN
, MF_BYCOMMAND
);
146 uIDMax
= Shell_MergeMenus(hmenu
, GetSubMenu(hmenures
, 0), indexMenu
, idCmdFirst
, idCmdLast
, MM_SUBMENUSHAVEIDS
);
148 DestroyMenu(hmenures
);
154 mi
.cbSize
= sizeof(mi
);
155 mi
.fMask
= MIIM_ID
| MIIM_STRING
| MIIM_FTYPE
;
158 GetMenuItemInfoW(hmenu
, FCIDM_SHVIEW_EXPLORE
, MF_BYCOMMAND
, &mi
);
159 RemoveMenu(hmenu
, FCIDM_SHVIEW_EXPLORE
+ idCmdFirst
, MF_BYCOMMAND
);
161 mi
.cbSize
= sizeof(mi
);
162 mi
.fMask
= MIIM_ID
| MIIM_TYPE
| MIIM_STATE
| MIIM_STRING
;
164 mi
.fState
= MFS_ENABLED
;
165 mi
.wID
= FCIDM_SHVIEW_EXPLORE
;
166 mi
.fType
= MFT_STRING
;
167 InsertMenuItemW(hmenu
, (uFlags
& CMF_EXPLORE
) ? 1 : 2, MF_BYPOSITION
, &mi
);
170 SetMenuDefaultItem(hmenu
, 0, MF_BYPOSITION
);
172 if(uFlags
& ~CMF_CANRENAME
)
173 RemoveMenu(hmenu
, FCIDM_SHVIEW_RENAME
, MF_BYCOMMAND
);
176 UINT enable
= MF_BYCOMMAND
;
178 /* can't rename more than one item at a time*/
179 if (!This
->apidl
|| This
->cidl
> 1)
180 enable
|= MFS_DISABLED
;
183 DWORD attr
= SFGAO_CANRENAME
;
185 IShellFolder_GetAttributesOf(This
->parent
, 1, (LPCITEMIDLIST
*)This
->apidl
, &attr
);
186 enable
|= (attr
& SFGAO_CANRENAME
) ? MFS_ENABLED
: MFS_DISABLED
;
189 EnableMenuItem(hmenu
, FCIDM_SHVIEW_RENAME
, enable
);
192 return MAKE_HRESULT(SEVERITY_SUCCESS
, 0, uIDMax
-idCmdFirst
);
194 return MAKE_HRESULT(SEVERITY_SUCCESS
, 0, 0);
197 /**************************************************************************
203 static void DoOpenExplore(ContextMenu
*This
, HWND hwnd
, LPCSTR verb
)
206 BOOL bFolderFound
= FALSE
;
208 SHELLEXECUTEINFOA sei
;
210 /* Find the first item in the list that is not a value. These commands
211 should never be invoked if there isn't at least one folder item in the list.*/
213 for(i
= 0; i
<This
->cidl
; i
++)
215 if(!_ILIsValue(This
->apidl
[i
]))
222 if (!bFolderFound
) return;
224 pidlFQ
= ILCombine(This
->pidl
, This
->apidl
[i
]);
226 ZeroMemory(&sei
, sizeof(sei
));
227 sei
.cbSize
= sizeof(sei
);
228 sei
.fMask
= SEE_MASK_IDLIST
| SEE_MASK_CLASSNAME
;
229 sei
.lpIDList
= pidlFQ
;
230 sei
.lpClass
= "Folder";
232 sei
.nShow
= SW_SHOWNORMAL
;
234 ShellExecuteExA(&sei
);
238 /**************************************************************************
241 * deletes the currently selected items
243 static void DoDelete(ContextMenu
*This
)
247 IShellFolder_QueryInterface(This
->parent
, &IID_ISFHelper
, (void**)&helper
);
250 ISFHelper_DeleteItems(helper
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
);
251 ISFHelper_Release(helper
);
255 /**************************************************************************
258 * copies the currently selected items into the clipboard
260 static void DoCopyOrCut(ContextMenu
*This
, HWND hwnd
, BOOL cut
)
262 IDataObject
*dataobject
;
264 TRACE("(%p)->(wnd=%p, cut=%d)\n", This
, hwnd
, cut
);
266 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This
->parent
, hwnd
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
, &IID_IDataObject
, 0, (void**)&dataobject
)))
268 OleSetClipboard(dataobject
);
269 IDataObject_Release(dataobject
);
273 /**************************************************************************
274 * Properties_AddPropSheetCallback
276 * Used by DoOpenProperties through SHCreatePropSheetExtArrayEx to add
277 * propertysheet pages from shell extensions.
279 static BOOL CALLBACK
Properties_AddPropSheetCallback(HPROPSHEETPAGE hpage
, LPARAM lparam
)
281 LPPROPSHEETHEADERW psh
= (LPPROPSHEETHEADERW
) lparam
;
282 psh
->u3
.phpage
[psh
->nPages
++] = hpage
;
287 #define MAX_PROP_PAGES 99
289 static void DoOpenProperties(ContextMenu
*This
, HWND hwnd
)
291 static const WCHAR wszFolder
[] = {'F','o','l','d','e','r', 0};
292 static const WCHAR wszFiletypeAll
[] = {'*',0};
293 LPSHELLFOLDER lpDesktopSF
;
296 WCHAR wszFiletype
[MAX_PATH
];
297 WCHAR wszFilename
[MAX_PATH
];
298 PROPSHEETHEADERW psh
;
299 HPROPSHEETPAGE hpages
[MAX_PROP_PAGES
];
303 TRACE("(%p)->(wnd=%p)\n", This
, hwnd
);
305 ZeroMemory(&psh
, sizeof(PROPSHEETHEADERW
));
306 psh
.dwSize
= sizeof (PROPSHEETHEADERW
);
307 psh
.hwndParent
= hwnd
;
308 psh
.dwFlags
= PSH_PROPTITLE
;
310 psh
.u3
.phpage
= hpages
;
311 psh
.u2
.nStartPage
= 0;
313 _ILSimpleGetTextW(This
->apidl
[0], (LPVOID
)wszFilename
, MAX_PATH
);
314 psh
.pszCaption
= (LPCWSTR
)wszFilename
;
316 /* Find out where to look for the shell extensions */
317 if (_ILIsValue(This
->apidl
[0]))
321 if (_ILGetExtension(This
->apidl
[0], sTemp
, 64))
323 HCR_MapTypeToValueA(sTemp
, sTemp
, 64, TRUE
);
324 MultiByteToWideChar(CP_ACP
, 0, sTemp
, -1, wszFiletype
, MAX_PATH
);
331 else if (_ILIsFolder(This
->apidl
[0]))
333 lstrcpynW(wszFiletype
, wszFolder
, 64);
335 else if (_ILIsSpecialFolder(This
->apidl
[0]))
338 static const WCHAR wszclsid
[] = {'C','L','S','I','D','\\', 0};
339 folderGUID
= _ILGetGUIDPointer(This
->apidl
[0]);
340 lstrcpyW(wszFiletype
, wszclsid
);
341 StringFromGUID2(folderGUID
, &wszFiletype
[6], MAX_PATH
- 6);
345 FIXME("Requested properties for unknown type.\n");
349 /* Get a suitable DataObject for accessing the files */
350 SHGetDesktopFolder(&lpDesktopSF
);
351 if (_ILIsPidlSimple(This
->pidl
))
353 ret
= IShellFolder_GetUIObjectOf(lpDesktopSF
, hwnd
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
,
354 &IID_IDataObject
, NULL
, (LPVOID
*)&lpDo
);
355 IShellFolder_Release(lpDesktopSF
);
359 IShellFolder_BindToObject(lpDesktopSF
, This
->pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*) &lpSF
);
360 ret
= IShellFolder_GetUIObjectOf(lpSF
, hwnd
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
,
361 &IID_IDataObject
, NULL
, (LPVOID
*)&lpDo
);
362 IShellFolder_Release(lpSF
);
363 IShellFolder_Release(lpDesktopSF
);
368 hpsxa
= SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT
, wszFiletype
, MAX_PROP_PAGES
- psh
.nPages
, lpDo
);
371 SHAddFromPropSheetExtArray(hpsxa
, Properties_AddPropSheetCallback
, (LPARAM
)&psh
);
372 SHDestroyPropSheetExtArray(hpsxa
);
374 hpsxa
= SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT
, wszFiletypeAll
, MAX_PROP_PAGES
- psh
.nPages
, lpDo
);
377 SHAddFromPropSheetExtArray(hpsxa
, Properties_AddPropSheetCallback
, (LPARAM
)&psh
);
378 SHDestroyPropSheetExtArray(hpsxa
);
380 IDataObject_Release(lpDo
);
384 PropertySheetW(&psh
);
386 FIXME("No property pages found.\n");
389 static HRESULT WINAPI
ItemMenu_InvokeCommand(
390 IContextMenu3
*iface
,
391 LPCMINVOKECOMMANDINFO lpcmi
)
393 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
395 if (lpcmi
->cbSize
!= sizeof(CMINVOKECOMMANDINFO
))
396 FIXME("Is an EX structure\n");
398 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This
,lpcmi
,lpcmi
->lpVerb
, lpcmi
->hwnd
);
400 if( HIWORD(lpcmi
->lpVerb
)==0 && LOWORD(lpcmi
->lpVerb
) > FCIDM_SHVIEWLAST
)
402 TRACE("Invalid Verb %x\n",LOWORD(lpcmi
->lpVerb
));
406 if (HIWORD(lpcmi
->lpVerb
) == 0)
408 switch(LOWORD(lpcmi
->lpVerb
))
410 case FCIDM_SHVIEW_EXPLORE
:
411 TRACE("Verb FCIDM_SHVIEW_EXPLORE\n");
412 DoOpenExplore(This
, lpcmi
->hwnd
, "explore");
414 case FCIDM_SHVIEW_OPEN
:
415 TRACE("Verb FCIDM_SHVIEW_OPEN\n");
416 DoOpenExplore(This
, lpcmi
->hwnd
, "open");
418 case FCIDM_SHVIEW_RENAME
:
420 IShellBrowser
*browser
;
422 /* get the active IShellView */
423 browser
= (IShellBrowser
*)SendMessageA(lpcmi
->hwnd
, CWM_GETISHELLBROWSER
, 0, 0);
428 if(SUCCEEDED(IShellBrowser_QueryActiveShellView(browser
, &view
)))
430 TRACE("(shellview=%p)\n", view
);
431 IShellView_SelectItem(view
, This
->apidl
[0],
432 SVSI_DESELECTOTHERS
|SVSI_EDIT
|SVSI_ENSUREVISIBLE
|SVSI_FOCUSED
|SVSI_SELECT
);
433 IShellView_Release(view
);
438 case FCIDM_SHVIEW_DELETE
:
439 TRACE("Verb FCIDM_SHVIEW_DELETE\n");
442 case FCIDM_SHVIEW_COPY
:
443 TRACE("Verb FCIDM_SHVIEW_COPY\n");
444 DoCopyOrCut(This
, lpcmi
->hwnd
, FALSE
);
446 case FCIDM_SHVIEW_CUT
:
447 TRACE("Verb FCIDM_SHVIEW_CUT\n");
448 DoCopyOrCut(This
, lpcmi
->hwnd
, TRUE
);
450 case FCIDM_SHVIEW_PROPERTIES
:
451 TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n");
452 DoOpenProperties(This
, lpcmi
->hwnd
);
455 FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi
->lpVerb
));
461 TRACE("Verb is %s\n",debugstr_a(lpcmi
->lpVerb
));
462 if (strcmp(lpcmi
->lpVerb
,"delete")==0)
464 else if (strcmp(lpcmi
->lpVerb
,"properties")==0)
465 DoOpenProperties(This
, lpcmi
->hwnd
);
467 FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi
->lpVerb
));
474 static HRESULT WINAPI
ItemMenu_GetCommandString(
475 IContextMenu3
*iface
,
482 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
483 HRESULT hr
= E_INVALIDARG
;
485 TRACE("(%p)->(%lx flags=%x %p name=%p len=%x)\n", This
, idCommand
, uFlags
, lpReserved
, lpszName
, uMaxNameLen
);
497 case FCIDM_SHVIEW_OPEN
:
498 strcpy(lpszName
, "open");
501 case FCIDM_SHVIEW_EXPLORE
:
502 strcpy(lpszName
, "explore");
505 case FCIDM_SHVIEW_CUT
:
506 strcpy(lpszName
, "cut");
509 case FCIDM_SHVIEW_COPY
:
510 strcpy(lpszName
, "copy");
513 case FCIDM_SHVIEW_CREATELINK
:
514 strcpy(lpszName
, "link");
517 case FCIDM_SHVIEW_DELETE
:
518 strcpy(lpszName
, "delete");
521 case FCIDM_SHVIEW_PROPERTIES
:
522 strcpy(lpszName
, "properties");
525 case FCIDM_SHVIEW_RENAME
:
526 strcpy(lpszName
, "rename");
532 /* NT 4.0 with IE 3.0x or no IE will always call This with GCS_VERBW. In This
533 case, you need to do the lstrcpyW to the pointer passed.*/
537 case FCIDM_SHVIEW_OPEN
:
538 MultiByteToWideChar(CP_ACP
, 0, "open", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
541 case FCIDM_SHVIEW_EXPLORE
:
542 MultiByteToWideChar(CP_ACP
, 0, "explore", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
545 case FCIDM_SHVIEW_CUT
:
546 MultiByteToWideChar(CP_ACP
, 0, "cut", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
549 case FCIDM_SHVIEW_COPY
:
550 MultiByteToWideChar(CP_ACP
, 0, "copy", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
553 case FCIDM_SHVIEW_CREATELINK
:
554 MultiByteToWideChar(CP_ACP
, 0, "link", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
557 case FCIDM_SHVIEW_DELETE
:
558 MultiByteToWideChar(CP_ACP
, 0, "delete", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
561 case FCIDM_SHVIEW_PROPERTIES
:
562 MultiByteToWideChar(CP_ACP
, 0, "properties", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
565 case FCIDM_SHVIEW_RENAME
:
566 MultiByteToWideChar( CP_ACP
, 0, "rename", -1, (LPWSTR
)lpszName
, uMaxNameLen
);
577 TRACE("-- (%p)->(name=%s)\n", This
, lpszName
);
581 /**************************************************************************
583 * should be only in IContextMenu2 and IContextMenu3
584 * is nevertheless called from word95
586 static HRESULT WINAPI
ContextMenu_HandleMenuMsg(IContextMenu3
*iface
, UINT msg
,
587 WPARAM wParam
, LPARAM lParam
)
589 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
590 FIXME("(%p)->(0x%x 0x%lx 0x%lx): stub\n", This
, msg
, wParam
, lParam
);
594 static HRESULT WINAPI
ContextMenu_HandleMenuMsg2(IContextMenu3
*iface
, UINT msg
,
595 WPARAM wParam
, LPARAM lParam
, LRESULT
*result
)
597 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
598 FIXME("(%p)->(0x%x 0x%lx 0x%lx %p): stub\n", This
, msg
, wParam
, lParam
, result
);
602 static const IContextMenu3Vtbl ItemContextMenuVtbl
=
604 ContextMenu_QueryInterface
,
607 ItemMenu_QueryContextMenu
,
608 ItemMenu_InvokeCommand
,
609 ItemMenu_GetCommandString
,
610 ContextMenu_HandleMenuMsg
,
611 ContextMenu_HandleMenuMsg2
614 HRESULT
ItemMenu_Constructor(IShellFolder
*parent
, LPCITEMIDLIST pidl
, const LPCITEMIDLIST
*apidl
, UINT cidl
,
615 REFIID riid
, void **pObj
)
621 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
622 if (!This
) return E_OUTOFMEMORY
;
624 This
->IContextMenu3_iface
.lpVtbl
= &ItemContextMenuVtbl
;
626 This
->parent
= parent
;
627 if (parent
) IShellFolder_AddRef(parent
);
629 This
->pidl
= ILClone(pidl
);
630 This
->apidl
= _ILCopyaPidl(apidl
, cidl
);
632 This
->allvalues
= TRUE
;
634 This
->desktop
= FALSE
;
636 for (i
= 0; i
< cidl
; i
++)
637 This
->allvalues
&= (_ILIsValue(apidl
[i
]) ? 1 : 0);
639 hr
= IContextMenu3_QueryInterface(&This
->IContextMenu3_iface
, riid
, pObj
);
640 IContextMenu3_Release(&This
->IContextMenu3_iface
);
645 /* Background menu implementation */
646 static HRESULT WINAPI
BackgroundMenu_QueryContextMenu(
647 IContextMenu3
*iface
,
654 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
659 TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",
660 This
, hMenu
, indexMenu
, idCmdFirst
, idCmdLast
, uFlags
);
662 hMyMenu
= LoadMenuA(shell32_hInstance
, "MENU_002");
663 if (uFlags
& CMF_DEFAULTONLY
)
665 HMENU ourMenu
= GetSubMenu(hMyMenu
,0);
666 UINT oldDef
= GetMenuDefaultItem(hMenu
,TRUE
,GMDI_USEDISABLED
);
667 UINT newDef
= GetMenuDefaultItem(ourMenu
,TRUE
,GMDI_USEDISABLED
);
668 if (newDef
!= oldDef
)
669 SetMenuDefaultItem(hMenu
,newDef
,TRUE
);
670 if (newDef
!=0xFFFFFFFF)
671 hr
= MAKE_HRESULT(SEVERITY_SUCCESS
, FACILITY_NULL
, newDef
+1);
673 hr
= MAKE_HRESULT(SEVERITY_SUCCESS
, FACILITY_NULL
, 0);
677 idMax
= Shell_MergeMenus (hMenu
, GetSubMenu(hMyMenu
,0), indexMenu
,
678 idCmdFirst
, idCmdLast
, MM_SUBMENUSHAVEIDS
);
679 hr
= MAKE_HRESULT(SEVERITY_SUCCESS
, FACILITY_NULL
, idMax
-idCmdFirst
);
681 DestroyMenu(hMyMenu
);
683 TRACE("(%p)->returning 0x%x\n",This
,hr
);
687 static void DoNewFolder(ContextMenu
*This
, IShellView
*view
)
691 IShellFolder_QueryInterface(This
->parent
, &IID_ISFHelper
, (void**)&helper
);
694 WCHAR nameW
[MAX_PATH
];
697 ISFHelper_GetUniqueName(helper
, nameW
, MAX_PATH
);
698 ISFHelper_AddFolder(helper
, 0, nameW
, &pidl
);
702 /* if we are in a shellview do labeledit */
703 IShellView_SelectItem(view
,
704 pidl
,(SVSI_DESELECTOTHERS
| SVSI_EDIT
| SVSI_ENSUREVISIBLE
705 |SVSI_FOCUSED
|SVSI_SELECT
));
709 ISFHelper_Release(helper
);
713 static BOOL
DoPaste(ContextMenu
*This
)
715 BOOL bSuccess
= FALSE
;
720 if(SUCCEEDED(OleGetClipboard(&pda
)))
725 TRACE("pda=%p\n", pda
);
727 /* Set the FORMATETC structure*/
728 InitFormatEtc(formatetc
, RegisterClipboardFormatW(CFSTR_SHELLIDLISTW
), TYMED_HGLOBAL
);
730 /* Get the pidls from IDataObject */
731 if(SUCCEEDED(IDataObject_GetData(pda
,&formatetc
,&medium
)))
733 LPITEMIDLIST
* apidl
;
735 IShellFolder
*psfFrom
= NULL
, *psfDesktop
;
737 LPIDA lpcida
= GlobalLock(medium
.u
.hGlobal
);
738 TRACE("cida=%p\n", lpcida
);
740 apidl
= _ILCopyCidaToaPidl(&pidl
, lpcida
);
742 /* bind to the source shellfolder */
743 SHGetDesktopFolder(&psfDesktop
);
746 IShellFolder_BindToObject(psfDesktop
, pidl
, NULL
, &IID_IShellFolder
, (LPVOID
*)&psfFrom
);
747 IShellFolder_Release(psfDesktop
);
752 /* get source and destination shellfolder */
753 ISFHelper
*psfhlpdst
, *psfhlpsrc
;
754 IShellFolder_QueryInterface(This
->parent
, &IID_ISFHelper
, (void**)&psfhlpdst
);
755 IShellFolder_QueryInterface(psfFrom
, &IID_ISFHelper
, (void**)&psfhlpsrc
);
757 /* do the copy/move */
758 if (psfhlpdst
&& psfhlpsrc
)
760 ISFHelper_CopyItems(psfhlpdst
, psfFrom
, lpcida
->cidl
, (LPCITEMIDLIST
*)apidl
);
762 ISFHelper_DeleteItems(psfhlpsrc, lpcida->cidl, apidl);
765 if(psfhlpdst
) ISFHelper_Release(psfhlpdst
);
766 if(psfhlpsrc
) ISFHelper_Release(psfhlpsrc
);
767 IShellFolder_Release(psfFrom
);
770 _ILFreeaPidl(apidl
, lpcida
->cidl
);
773 /* release the medium*/
774 ReleaseStgMedium(&medium
);
776 IDataObject_Release(pda
);
782 hMem
= GetClipboardData(CF_HDROP
);
786 char * pDropFiles
= GlobalLock(hMem
);
789 int len
, offset
= sizeof(DROPFILESTRUCT
);
791 while( pDropFiles
[offset
] != 0)
793 len
= strlen(pDropFiles
+ offset
);
794 TRACE("%s\n", pDropFiles
+ offset
);
805 static HRESULT WINAPI
BackgroundMenu_InvokeCommand(
806 IContextMenu3
*iface
,
807 LPCMINVOKECOMMANDINFO lpcmi
)
809 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
810 IShellBrowser
*browser
;
811 IShellView
*view
= NULL
;
814 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n", This
, lpcmi
, lpcmi
->lpVerb
, lpcmi
->hwnd
);
816 /* get the active IShellView */
817 if ((browser
= (IShellBrowser
*)SendMessageA(lpcmi
->hwnd
, CWM_GETISHELLBROWSER
, 0, 0)))
819 if (SUCCEEDED(IShellBrowser_QueryActiveShellView(browser
, &view
)))
820 IShellView_GetWindow(view
, &hWnd
);
823 if(HIWORD(lpcmi
->lpVerb
))
825 TRACE("%s\n", debugstr_a(lpcmi
->lpVerb
));
827 if (!strcmp(lpcmi
->lpVerb
, CMDSTR_NEWFOLDERA
))
829 DoNewFolder(This
, view
);
831 else if (!strcmp(lpcmi
->lpVerb
, CMDSTR_VIEWLISTA
))
833 if (hWnd
) SendMessageA(hWnd
, WM_COMMAND
, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW
, 0), 0);
835 else if (!strcmp(lpcmi
->lpVerb
, CMDSTR_VIEWDETAILSA
))
837 if (hWnd
) SendMessageA(hWnd
, WM_COMMAND
, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW
, 0), 0);
841 FIXME("please report: unknown verb %s\n", debugstr_a(lpcmi
->lpVerb
));
846 switch (LOWORD(lpcmi
->lpVerb
))
848 case FCIDM_SHVIEW_REFRESH
:
849 if (view
) IShellView_Refresh(view
);
852 case FCIDM_SHVIEW_NEWFOLDER
:
853 DoNewFolder(This
, view
);
856 case FCIDM_SHVIEW_INSERT
:
860 case FCIDM_SHVIEW_PROPERTIES
:
862 ShellExecuteA(lpcmi
->hwnd
, "open", "rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL
, NULL
, SW_SHOWNORMAL
);
864 FIXME("launch item properties dialog\n");
869 /* if it's an id just pass it to the parent shv */
870 if (hWnd
) SendMessageA(hWnd
, WM_COMMAND
, MAKEWPARAM(LOWORD(lpcmi
->lpVerb
), 0), 0);
876 IShellView_Release(view
);
881 static HRESULT WINAPI
BackgroundMenu_GetCommandString(
882 IContextMenu3
*iface
,
889 ContextMenu
*This
= impl_from_IContextMenu3(iface
);
891 TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This
, idCommand
, uFlags
, lpReserved
, lpszName
, uMaxNameLen
);
893 /* test the existence of the menu items, the file dialog enables
894 the buttons according to this */
895 if (uFlags
== GCS_VALIDATEA
)
897 if(HIWORD(idCommand
))
899 if (!strcmp((LPSTR
)idCommand
, CMDSTR_VIEWLISTA
) ||
900 !strcmp((LPSTR
)idCommand
, CMDSTR_VIEWDETAILSA
) ||
901 !strcmp((LPSTR
)idCommand
, CMDSTR_NEWFOLDERA
))
908 FIXME("unknown command string\n");
912 static const IContextMenu3Vtbl BackgroundContextMenuVtbl
=
914 ContextMenu_QueryInterface
,
917 BackgroundMenu_QueryContextMenu
,
918 BackgroundMenu_InvokeCommand
,
919 BackgroundMenu_GetCommandString
,
920 ContextMenu_HandleMenuMsg
,
921 ContextMenu_HandleMenuMsg2
924 HRESULT
BackgroundMenu_Constructor(IShellFolder
*parent
, BOOL desktop
, REFIID riid
, void **pObj
)
929 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
930 if (!This
) return E_OUTOFMEMORY
;
932 This
->IContextMenu3_iface
.lpVtbl
= &BackgroundContextMenuVtbl
;
934 This
->parent
= parent
;
939 This
->allvalues
= FALSE
;
941 This
->desktop
= desktop
;
942 if (parent
) IShellFolder_AddRef(parent
);
944 hr
= IContextMenu3_QueryInterface(&This
->IContextMenu3_iface
, riid
, pObj
);
945 IContextMenu3_Release(&This
->IContextMenu3_iface
);