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
26 #define NONAMELESSSTRUCT
29 #include "wine/debug.h"
34 #include "undocshell.h"
39 #include "shell32_main.h"
40 #include "shellfolder.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(shell);
48 IContextMenu3 IContextMenu3_iface;
55 LPITEMIDLIST pidl; /* root pidl */
56 LPITEMIDLIST *apidl; /* array of child pidls */
60 /* background menu data */
64 static inline ContextMenu *impl_from_IContextMenu3(IContextMenu3 *iface)
66 return CONTAINING_RECORD(iface, ContextMenu, IContextMenu3_iface);
69 static HRESULT WINAPI ContextMenu_QueryInterface(IContextMenu3 *iface, REFIID riid, LPVOID *ppvObj)
71 ContextMenu *This = impl_from_IContextMenu3(iface);
73 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
77 if (IsEqualIID(riid, &IID_IUnknown) ||
78 IsEqualIID(riid, &IID_IContextMenu) ||
79 IsEqualIID(riid, &IID_IContextMenu2) ||
80 IsEqualIID(riid, &IID_IContextMenu3))
84 else if (IsEqualIID(riid, &IID_IShellExtInit)) /*IShellExtInit*/
86 FIXME("-- LPSHELLEXTINIT pointer requested\n");
91 IContextMenu3_AddRef(iface);
95 TRACE("-- Interface: E_NOINTERFACE\n");
99 static ULONG WINAPI ContextMenu_AddRef(IContextMenu3 *iface)
101 ContextMenu *This = impl_from_IContextMenu3(iface);
102 ULONG ref = InterlockedIncrement(&This->ref);
103 TRACE("(%p)->(%u)\n", This, ref);
107 static ULONG WINAPI ContextMenu_Release(IContextMenu3 *iface)
109 ContextMenu *This = impl_from_IContextMenu3(iface);
110 ULONG ref = InterlockedDecrement(&This->ref);
112 TRACE("(%p)->(%u)\n", This, ref);
117 IShellFolder_Release(This->parent);
120 _ILFreeaPidl(This->apidl, This->cidl);
122 HeapFree(GetProcessHeap(), 0, This);
128 static HRESULT WINAPI ItemMenu_QueryContextMenu(
129 IContextMenu3 *iface,
136 ContextMenu *This = impl_from_IContextMenu3(iface);
139 TRACE("(%p)->(%p %d 0x%x 0x%x 0x%x )\n", This, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
141 This->verb_offset = idCmdFirst;
143 if(!(CMF_DEFAULTONLY & uFlags) && This->cidl > 0)
145 HMENU hmenures = LoadMenuW(shell32_hInstance, MAKEINTRESOURCEW(MENU_SHV_FILE));
147 if(uFlags & CMF_EXPLORE)
148 RemoveMenu(hmenures, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
150 uIDMax = Shell_MergeMenus(hmenu, GetSubMenu(hmenures, 0), indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
152 DestroyMenu(hmenures);
158 mi.cbSize = sizeof(mi);
159 mi.fMask = MIIM_ID | MIIM_STRING | MIIM_FTYPE;
162 GetMenuItemInfoW(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND, &mi);
163 RemoveMenu(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND);
165 mi.cbSize = sizeof(mi);
166 mi.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
168 mi.fState = MFS_ENABLED;
169 mi.wID = FCIDM_SHVIEW_EXPLORE;
170 mi.fType = MFT_STRING;
171 InsertMenuItemW(hmenu, (uFlags & CMF_EXPLORE) ? 1 : 2, MF_BYPOSITION, &mi);
174 SetMenuDefaultItem(hmenu, 0, MF_BYPOSITION);
176 if(uFlags & ~CMF_CANRENAME)
177 RemoveMenu(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND);
180 UINT enable = MF_BYCOMMAND;
182 /* can't rename more than one item at a time*/
183 if (!This->apidl || This->cidl > 1)
184 enable |= MFS_DISABLED;
187 DWORD attr = SFGAO_CANRENAME;
189 IShellFolder_GetAttributesOf(This->parent, 1, (LPCITEMIDLIST*)This->apidl, &attr);
190 enable |= (attr & SFGAO_CANRENAME) ? MFS_ENABLED : MFS_DISABLED;
193 EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME, enable);
196 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, uIDMax-idCmdFirst);
198 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
201 /**************************************************************************
207 static void DoOpenExplore(ContextMenu *This, HWND hwnd, LPCSTR verb)
209 UINT i, bFolderFound = FALSE;
211 SHELLEXECUTEINFOA sei;
213 /* Find the first item in the list that is not a value. These commands
214 should never be invoked if there isn't at least one folder item in the list.*/
216 for(i = 0; i<This->cidl; i++)
218 if(!_ILIsValue(This->apidl[i]))
225 if (!bFolderFound) return;
227 pidlFQ = ILCombine(This->pidl, This->apidl[i]);
229 ZeroMemory(&sei, sizeof(sei));
230 sei.cbSize = sizeof(sei);
231 sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
232 sei.lpIDList = pidlFQ;
233 sei.lpClass = "Folder";
235 sei.nShow = SW_SHOWNORMAL;
237 ShellExecuteExA(&sei);
241 /**************************************************************************
244 * deletes the currently selected items
246 static void DoDelete(ContextMenu *This)
250 IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&helper);
253 ISFHelper_DeleteItems(helper, This->cidl, (LPCITEMIDLIST*)This->apidl);
254 ISFHelper_Release(helper);
258 /**************************************************************************
261 * copies the currently selected items into the clipboard
263 static BOOL DoCopyOrCut(ContextMenu *This, HWND hwnd, BOOL cut)
265 IDataObject *dataobject;
266 IShellBrowser *browser;
269 TRACE("(%p)->(wnd=%p, cut=%d)\n", This, hwnd, cut);
271 /* get the active IShellView */
272 if ((browser = (IShellBrowser*)SendMessageA(hwnd, CWM_GETISHELLBROWSER, 0, 0)))
274 if (SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
276 if (SUCCEEDED(IShellView_GetItemObject(view, SVGIO_SELECTION, &IID_IDataObject, (void**)&dataobject)))
278 OleSetClipboard(dataobject);
279 IDataObject_Release(dataobject);
281 IShellView_Release(view);
288 /**************************************************************************
289 * Properties_AddPropSheetCallback
291 * Used by DoOpenProperties through SHCreatePropSheetExtArrayEx to add
292 * propertysheet pages from shell extensions.
294 static BOOL CALLBACK Properties_AddPropSheetCallback(HPROPSHEETPAGE hpage, LPARAM lparam)
296 LPPROPSHEETHEADERW psh = (LPPROPSHEETHEADERW) lparam;
297 psh->u3.phpage[psh->nPages++] = hpage;
302 static void DoOpenProperties(ContextMenu *This, HWND hwnd)
304 static const UINT MAX_PROP_PAGES = 99;
305 static const WCHAR wszFolder[] = {'F','o','l','d','e','r', 0};
306 static const WCHAR wszFiletypeAll[] = {'*',0};
307 LPSHELLFOLDER lpDesktopSF;
310 WCHAR wszFiletype[MAX_PATH];
311 WCHAR wszFilename[MAX_PATH];
312 PROPSHEETHEADERW psh;
313 HPROPSHEETPAGE hpages[MAX_PROP_PAGES];
317 TRACE("(%p)->(wnd=%p)\n", This, hwnd);
319 ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
320 psh.dwSize = sizeof (PROPSHEETHEADERW);
321 psh.hwndParent = hwnd;
322 psh.dwFlags = PSH_PROPTITLE;
324 psh.u3.phpage = hpages;
325 psh.u2.nStartPage = 0;
327 _ILSimpleGetTextW(This->apidl[0], (LPVOID)wszFilename, MAX_PATH);
328 psh.pszCaption = (LPCWSTR)wszFilename;
330 /* Find out where to look for the shell extensions */
331 if (_ILIsValue(This->apidl[0]))
335 if (_ILGetExtension(This->apidl[0], sTemp, 64))
337 HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE);
338 MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wszFiletype, MAX_PATH);
345 else if (_ILIsFolder(This->apidl[0]))
347 lstrcpynW(wszFiletype, wszFolder, 64);
349 else if (_ILIsSpecialFolder(This->apidl[0]))
352 static const WCHAR wszclsid[] = {'C','L','S','I','D','\\', 0};
353 folderGUID = _ILGetGUIDPointer(This->apidl[0]);
354 lstrcpyW(wszFiletype, wszclsid);
355 StringFromGUID2(folderGUID, &wszFiletype[6], MAX_PATH - 6);
359 FIXME("Requested properties for unknown type.\n");
363 /* Get a suitable DataObject for accessing the files */
364 SHGetDesktopFolder(&lpDesktopSF);
365 if (_ILIsPidlSimple(This->pidl))
367 ret = IShellFolder_GetUIObjectOf(lpDesktopSF, hwnd, This->cidl, (LPCITEMIDLIST*)This->apidl,
368 &IID_IDataObject, NULL, (LPVOID *)&lpDo);
369 IShellFolder_Release(lpDesktopSF);
373 IShellFolder_BindToObject(lpDesktopSF, This->pidl, NULL, &IID_IShellFolder, (LPVOID*) &lpSF);
374 ret = IShellFolder_GetUIObjectOf(lpSF, hwnd, This->cidl, (LPCITEMIDLIST*)This->apidl,
375 &IID_IDataObject, NULL, (LPVOID *)&lpDo);
376 IShellFolder_Release(lpSF);
377 IShellFolder_Release(lpDesktopSF);
382 hpsxa = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszFiletype, MAX_PROP_PAGES - psh.nPages, lpDo);
385 SHAddFromPropSheetExtArray(hpsxa, Properties_AddPropSheetCallback, (LPARAM)&psh);
386 SHDestroyPropSheetExtArray(hpsxa);
388 hpsxa = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszFiletypeAll, MAX_PROP_PAGES - psh.nPages, lpDo);
391 SHAddFromPropSheetExtArray(hpsxa, Properties_AddPropSheetCallback, (LPARAM)&psh);
392 SHDestroyPropSheetExtArray(hpsxa);
394 IDataObject_Release(lpDo);
398 PropertySheetW(&psh);
400 FIXME("No property pages found.\n");
403 static HRESULT WINAPI ItemMenu_InvokeCommand(
404 IContextMenu3 *iface,
405 LPCMINVOKECOMMANDINFO lpcmi)
407 ContextMenu *This = impl_from_IContextMenu3(iface);
409 if (lpcmi->cbSize != sizeof(CMINVOKECOMMANDINFO))
410 FIXME("Is an EX structure\n");
412 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);
414 if( HIWORD(lpcmi->lpVerb)==0 && LOWORD(lpcmi->lpVerb) > FCIDM_SHVIEWLAST)
416 TRACE("Invalid Verb %x\n",LOWORD(lpcmi->lpVerb));
420 if (HIWORD(lpcmi->lpVerb) == 0)
422 switch(LOWORD(lpcmi->lpVerb - This->verb_offset))
424 case FCIDM_SHVIEW_EXPLORE:
425 TRACE("Verb FCIDM_SHVIEW_EXPLORE\n");
426 DoOpenExplore(This, lpcmi->hwnd, "explore");
428 case FCIDM_SHVIEW_OPEN:
429 TRACE("Verb FCIDM_SHVIEW_OPEN\n");
430 DoOpenExplore(This, lpcmi->hwnd, "open");
432 case FCIDM_SHVIEW_RENAME:
434 IShellBrowser *browser;
436 /* get the active IShellView */
437 browser = (IShellBrowser*)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0);
442 if(SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
444 TRACE("(shellview=%p)\n", view);
445 IShellView_SelectItem(view, This->apidl[0],
446 SVSI_DESELECTOTHERS|SVSI_EDIT|SVSI_ENSUREVISIBLE|SVSI_FOCUSED|SVSI_SELECT);
447 IShellView_Release(view);
452 case FCIDM_SHVIEW_DELETE:
453 TRACE("Verb FCIDM_SHVIEW_DELETE\n");
456 case FCIDM_SHVIEW_COPY:
457 TRACE("Verb FCIDM_SHVIEW_COPY\n");
458 DoCopyOrCut(This, lpcmi->hwnd, FALSE);
460 case FCIDM_SHVIEW_CUT:
461 TRACE("Verb FCIDM_SHVIEW_CUT\n");
462 DoCopyOrCut(This, lpcmi->hwnd, TRUE);
464 case FCIDM_SHVIEW_PROPERTIES:
465 TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n");
466 DoOpenProperties(This, lpcmi->hwnd);
469 FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)-This->verb_offset);
475 TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb));
476 if (strcmp(lpcmi->lpVerb,"delete")==0)
478 else if (strcmp(lpcmi->lpVerb,"properties")==0)
479 DoOpenProperties(This, lpcmi->hwnd);
481 FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb));
488 static HRESULT WINAPI ItemMenu_GetCommandString(
489 IContextMenu3 *iface,
496 ContextMenu *This = impl_from_IContextMenu3(iface);
497 HRESULT hr = E_INVALIDARG;
499 TRACE("(%p)->(%lx flags=%x %p name=%p len=%x)\n", This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
509 switch(idCommand-This->verb_offset)
511 case FCIDM_SHVIEW_RENAME:
512 strcpy(lpszName, "rename");
518 /* NT 4.0 with IE 3.0x or no IE will always call This with GCS_VERBW. In This
519 case, you need to do the lstrcpyW to the pointer passed.*/
521 switch(idCommand-This->verb_offset)
523 case FCIDM_SHVIEW_RENAME:
524 MultiByteToWideChar( CP_ACP, 0, "rename", -1, (LPWSTR)lpszName, uMaxNameLen );
535 TRACE("-- (%p)->(name=%s)\n", This, lpszName);
539 /**************************************************************************
541 * should be only in IContextMenu2 and IContextMenu3
542 * is nevertheless called from word95
544 static HRESULT WINAPI ContextMenu_HandleMenuMsg(IContextMenu3 *iface, UINT msg,
545 WPARAM wParam, LPARAM lParam)
547 ContextMenu *This = impl_from_IContextMenu3(iface);
548 FIXME("(%p)->(0x%x 0x%lx 0x%lx): stub\n", This, msg, wParam, lParam);
552 static HRESULT WINAPI ContextMenu_HandleMenuMsg2(IContextMenu3 *iface, UINT msg,
553 WPARAM wParam, LPARAM lParam, LRESULT *result)
555 ContextMenu *This = impl_from_IContextMenu3(iface);
556 FIXME("(%p)->(0x%x 0x%lx 0x%lx %p): stub\n", This, msg, wParam, lParam, result);
560 static const IContextMenu3Vtbl ItemContextMenuVtbl =
562 ContextMenu_QueryInterface,
565 ItemMenu_QueryContextMenu,
566 ItemMenu_InvokeCommand,
567 ItemMenu_GetCommandString,
568 ContextMenu_HandleMenuMsg,
569 ContextMenu_HandleMenuMsg2
572 HRESULT ItemMenu_Constructor(IShellFolder *parent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *apidl, UINT cidl,
573 REFIID riid, void **pObj)
579 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
580 if (!This) return E_OUTOFMEMORY;
582 This->IContextMenu3_iface.lpVtbl = &ItemContextMenuVtbl;
584 This->verb_offset = 0;
585 This->parent = parent;
586 if (parent) IShellFolder_AddRef(parent);
588 This->pidl = ILClone(pidl);
589 This->apidl = _ILCopyaPidl(apidl, cidl);
591 This->allvalues = TRUE;
593 This->desktop = FALSE;
595 for (i = 0; i < cidl; i++)
596 This->allvalues &= (_ILIsValue(apidl[i]) ? 1 : 0);
598 hr = IContextMenu3_QueryInterface(&This->IContextMenu3_iface, riid, pObj);
599 IContextMenu3_Release(&This->IContextMenu3_iface);
604 /* Background menu implementation */
605 static HRESULT WINAPI BackgroundMenu_QueryContextMenu(
606 IContextMenu3 *iface,
613 ContextMenu *This = impl_from_IContextMenu3(iface);
618 TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",
619 This, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
621 This->verb_offset = idCmdFirst;
623 hMyMenu = LoadMenuA(shell32_hInstance, "MENU_002");
624 if (uFlags & CMF_DEFAULTONLY)
626 HMENU ourMenu = GetSubMenu(hMyMenu,0);
627 UINT oldDef = GetMenuDefaultItem(hMenu,TRUE,GMDI_USEDISABLED);
628 UINT newDef = GetMenuDefaultItem(ourMenu,TRUE,GMDI_USEDISABLED);
629 if (newDef != oldDef)
630 SetMenuDefaultItem(hMenu,newDef,TRUE);
631 if (newDef!=0xFFFFFFFF)
632 hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, newDef+1);
634 hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
638 idMax = Shell_MergeMenus (hMenu, GetSubMenu(hMyMenu,0), indexMenu,
639 idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
640 hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, idMax-idCmdFirst);
642 DestroyMenu(hMyMenu);
644 TRACE("(%p)->returning 0x%x\n",This,hr);
648 static void DoNewFolder(ContextMenu *This, IShellView *view)
652 IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&helper);
655 WCHAR nameW[MAX_PATH];
658 ISFHelper_GetUniqueName(helper, nameW, MAX_PATH);
659 ISFHelper_AddFolder(helper, 0, nameW, &pidl);
663 /* if we are in a shellview do labeledit */
664 IShellView_SelectItem(view,
665 pidl,(SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE
666 |SVSI_FOCUSED|SVSI_SELECT));
670 ISFHelper_Release(helper);
674 static BOOL DoPaste(ContextMenu *This)
676 BOOL bSuccess = FALSE;
681 if(SUCCEEDED(OleGetClipboard(&pda)))
686 TRACE("pda=%p\n", pda);
688 /* Set the FORMATETC structure*/
689 InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLISTW), TYMED_HGLOBAL);
691 /* Get the pidls from IDataObject */
692 if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium)))
694 LPITEMIDLIST * apidl;
696 IShellFolder *psfFrom = NULL, *psfDesktop;
698 LPIDA lpcida = GlobalLock(medium.u.hGlobal);
699 TRACE("cida=%p\n", lpcida);
701 apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
703 /* bind to the source shellfolder */
704 SHGetDesktopFolder(&psfDesktop);
707 IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom);
708 IShellFolder_Release(psfDesktop);
713 /* get source and destination shellfolder */
714 ISFHelper *psfhlpdst, *psfhlpsrc;
715 IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&psfhlpdst);
716 IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (void**)&psfhlpsrc);
718 /* do the copy/move */
719 if (psfhlpdst && psfhlpsrc)
721 ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl);
723 ISFHelper_DeleteItems(psfhlpsrc, lpcida->cidl, apidl);
726 if(psfhlpdst) ISFHelper_Release(psfhlpdst);
727 if(psfhlpsrc) ISFHelper_Release(psfhlpsrc);
728 IShellFolder_Release(psfFrom);
731 _ILFreeaPidl(apidl, lpcida->cidl);
734 /* release the medium*/
735 ReleaseStgMedium(&medium);
737 IDataObject_Release(pda);
743 hMem = GetClipboardData(CF_HDROP);
747 char * pDropFiles = GlobalLock(hMem);
750 int len, offset = sizeof(DROPFILESTRUCT);
752 while( pDropFiles[offset] != 0)
754 len = strlen(pDropFiles + offset);
755 TRACE("%s\n", pDropFiles + offset);
766 static HRESULT WINAPI BackgroundMenu_InvokeCommand(
767 IContextMenu3 *iface,
768 LPCMINVOKECOMMANDINFO lpcmi)
770 ContextMenu *This = impl_from_IContextMenu3(iface);
771 IShellBrowser *browser;
772 IShellView *view = NULL;
775 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n", This, lpcmi, lpcmi->lpVerb, lpcmi->hwnd);
777 /* get the active IShellView */
778 if ((browser = (IShellBrowser*)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0)))
780 if (SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
781 IShellView_GetWindow(view, &hWnd);
784 if(HIWORD(lpcmi->lpVerb))
786 TRACE("%s\n", debugstr_a(lpcmi->lpVerb));
788 if (!strcmp(lpcmi->lpVerb, CMDSTR_NEWFOLDERA))
790 DoNewFolder(This, view);
792 else if (!strcmp(lpcmi->lpVerb, CMDSTR_VIEWLISTA))
794 if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW, 0), 0);
796 else if (!strcmp(lpcmi->lpVerb, CMDSTR_VIEWDETAILSA))
798 if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW, 0), 0);
802 FIXME("please report: unknown verb %s\n", debugstr_a(lpcmi->lpVerb));
807 switch (LOWORD(lpcmi->lpVerb) - This->verb_offset)
809 case FCIDM_SHVIEW_REFRESH:
810 if (view) IShellView_Refresh(view);
813 case FCIDM_SHVIEW_NEWFOLDER:
814 DoNewFolder(This, view);
817 case FCIDM_SHVIEW_INSERT:
821 case FCIDM_SHVIEW_PROPERTIES:
823 ShellExecuteA(lpcmi->hwnd, "open", "rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL);
825 FIXME("launch item properties dialog\n");
830 /* if it's an id just pass it to the parent shv */
831 if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0), 0);
837 IShellView_Release(view);
842 static HRESULT WINAPI BackgroundMenu_GetCommandString(
843 IContextMenu3 *iface,
850 ContextMenu *This = impl_from_IContextMenu3(iface);
852 TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
854 /* test the existence of the menu items, the file dialog enables
855 the buttons according to this */
856 if (uFlags == GCS_VALIDATEA)
858 if(HIWORD(idCommand))
860 if (!strcmp((LPSTR)idCommand, CMDSTR_VIEWLISTA) ||
861 !strcmp((LPSTR)idCommand, CMDSTR_VIEWDETAILSA) ||
862 !strcmp((LPSTR)idCommand, CMDSTR_NEWFOLDERA))
869 FIXME("unknown command string\n");
873 static const IContextMenu3Vtbl BackgroundContextMenuVtbl =
875 ContextMenu_QueryInterface,
878 BackgroundMenu_QueryContextMenu,
879 BackgroundMenu_InvokeCommand,
880 BackgroundMenu_GetCommandString,
881 ContextMenu_HandleMenuMsg,
882 ContextMenu_HandleMenuMsg2
885 HRESULT BackgroundMenu_Constructor(IShellFolder *parent, BOOL desktop, REFIID riid, void **pObj)
890 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
891 if (!This) return E_OUTOFMEMORY;
893 This->IContextMenu3_iface.lpVtbl = &BackgroundContextMenuVtbl;
895 This->parent = parent;
896 This->verb_offset = 0;
901 This->allvalues = FALSE;
903 This->desktop = desktop;
904 if (parent) IShellFolder_AddRef(parent);
906 hr = IContextMenu3_QueryInterface(&This->IContextMenu3_iface, riid, pObj);
907 IContextMenu3_Release(&This->IContextMenu3_iface);