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 IContextMenu2 IContextMenu2_iface;
55 LPITEMIDLIST pidl; /* root pidl */
56 LPITEMIDLIST *apidl; /* array of child pidls */
60 /* background menu data */
64 static inline ContextMenu *impl_from_IContextMenu2(IContextMenu2 *iface)
66 return CONTAINING_RECORD(iface, ContextMenu, IContextMenu2_iface);
69 static HRESULT WINAPI ContextMenu_QueryInterface(IContextMenu2 *iface, REFIID riid, LPVOID *ppvObj)
71 ContextMenu *This = impl_from_IContextMenu2(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))
83 else if (IsEqualIID(riid, &IID_IShellExtInit)) /*IShellExtInit*/
85 FIXME("-- LPSHELLEXTINIT pointer requested\n");
90 IContextMenu2_AddRef(iface);
94 TRACE("-- Interface: E_NOINTERFACE\n");
98 static ULONG WINAPI ContextMenu_AddRef(IContextMenu2 *iface)
100 ContextMenu *This = impl_from_IContextMenu2(iface);
101 ULONG ref = InterlockedIncrement(&This->ref);
102 TRACE("(%p)->(%u)\n", This, ref);
106 static ULONG WINAPI ContextMenu_Release(IContextMenu2 *iface)
108 ContextMenu *This = impl_from_IContextMenu2(iface);
109 ULONG ref = InterlockedDecrement(&This->ref);
111 TRACE("(%p)->(%u)\n", This, ref);
116 IShellFolder_Release(This->parent);
119 _ILFreeaPidl(This->apidl, This->cidl);
121 HeapFree(GetProcessHeap(), 0, This);
127 static HRESULT WINAPI ItemMenu_QueryContextMenu(
128 IContextMenu2 *iface,
135 ContextMenu *This = impl_from_IContextMenu2(iface);
138 TRACE("(%p)->(%p %d 0x%x 0x%x 0x%x )\n", This, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
140 This->verb_offset = idCmdFirst;
142 if(!(CMF_DEFAULTONLY & uFlags) && This->cidl > 0)
144 HMENU hmenures = LoadMenuW(shell32_hInstance, MAKEINTRESOURCEW(MENU_SHV_FILE));
146 if(uFlags & CMF_EXPLORE)
147 RemoveMenu(hmenures, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
149 uIDMax = Shell_MergeMenus(hmenu, GetSubMenu(hmenures, 0), indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
151 DestroyMenu(hmenures);
157 mi.cbSize = sizeof(mi);
158 mi.fMask = MIIM_ID | MIIM_STRING | MIIM_FTYPE;
161 GetMenuItemInfoW(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND, &mi);
162 RemoveMenu(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND);
164 mi.cbSize = sizeof(mi);
165 mi.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
167 mi.fState = MFS_ENABLED;
168 mi.wID = FCIDM_SHVIEW_EXPLORE;
169 mi.fType = MFT_STRING;
170 InsertMenuItemW(hmenu, (uFlags & CMF_EXPLORE) ? 1 : 2, MF_BYPOSITION, &mi);
173 SetMenuDefaultItem(hmenu, 0, MF_BYPOSITION);
175 if(uFlags & ~CMF_CANRENAME)
176 RemoveMenu(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND);
179 UINT enable = MF_BYCOMMAND;
181 /* can't rename more than one item at a time*/
182 if (!This->apidl || This->cidl > 1)
183 enable |= MFS_DISABLED;
186 DWORD attr = SFGAO_CANRENAME;
188 IShellFolder_GetAttributesOf(This->parent, 1, (LPCITEMIDLIST*)This->apidl, &attr);
189 enable |= (attr & SFGAO_CANRENAME) ? MFS_ENABLED : MFS_DISABLED;
192 EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME, enable);
195 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, uIDMax-idCmdFirst);
197 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
200 /**************************************************************************
206 static void DoOpenExplore(ContextMenu *This, HWND hwnd, LPCSTR verb)
208 UINT i, bFolderFound = FALSE;
210 SHELLEXECUTEINFOA sei;
212 /* Find the first item in the list that is not a value. These commands
213 should never be invoked if there isn't at least one folder item in the list.*/
215 for(i = 0; i<This->cidl; i++)
217 if(!_ILIsValue(This->apidl[i]))
224 if (!bFolderFound) return;
226 pidlFQ = ILCombine(This->pidl, This->apidl[i]);
228 ZeroMemory(&sei, sizeof(sei));
229 sei.cbSize = sizeof(sei);
230 sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
231 sei.lpIDList = pidlFQ;
232 sei.lpClass = "Folder";
234 sei.nShow = SW_SHOWNORMAL;
236 ShellExecuteExA(&sei);
240 /**************************************************************************
243 * deletes the currently selected items
245 static void DoDelete(ContextMenu *This)
249 IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&helper);
252 ISFHelper_DeleteItems(helper, This->cidl, (LPCITEMIDLIST*)This->apidl);
253 ISFHelper_Release(helper);
257 /**************************************************************************
260 * copies the currently selected items into the clipboard
262 static BOOL DoCopyOrCut(ContextMenu *This, HWND hwnd, BOOL cut)
264 IDataObject *dataobject;
265 IShellBrowser *browser;
268 TRACE("(%p)->(wnd=%p, cut=%d)\n", This, hwnd, cut);
270 /* get the active IShellView */
271 if ((browser = (IShellBrowser*)SendMessageA(hwnd, CWM_GETISHELLBROWSER, 0, 0)))
273 if (SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
275 if (SUCCEEDED(IShellView_GetItemObject(view, SVGIO_SELECTION, &IID_IDataObject, (void**)&dataobject)))
277 OleSetClipboard(dataobject);
278 IDataObject_Release(dataobject);
280 IShellView_Release(view);
287 /**************************************************************************
288 * Properties_AddPropSheetCallback
290 * Used by DoOpenProperties through SHCreatePropSheetExtArrayEx to add
291 * propertysheet pages from shell extensions.
293 static BOOL CALLBACK Properties_AddPropSheetCallback(HPROPSHEETPAGE hpage, LPARAM lparam)
295 LPPROPSHEETHEADERW psh = (LPPROPSHEETHEADERW) lparam;
296 psh->u3.phpage[psh->nPages++] = hpage;
301 static void DoOpenProperties(ContextMenu *This, HWND hwnd)
303 static const UINT MAX_PROP_PAGES = 99;
304 static const WCHAR wszFolder[] = {'F','o','l','d','e','r', 0};
305 static const WCHAR wszFiletypeAll[] = {'*',0};
306 LPSHELLFOLDER lpDesktopSF;
309 WCHAR wszFiletype[MAX_PATH];
310 WCHAR wszFilename[MAX_PATH];
311 PROPSHEETHEADERW psh;
312 HPROPSHEETPAGE hpages[MAX_PROP_PAGES];
316 TRACE("(%p)->(wnd=%p)\n", This, hwnd);
318 ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
319 psh.dwSize = sizeof (PROPSHEETHEADERW);
320 psh.hwndParent = hwnd;
321 psh.dwFlags = PSH_PROPTITLE;
323 psh.u3.phpage = hpages;
324 psh.u2.nStartPage = 0;
326 _ILSimpleGetTextW(This->apidl[0], (LPVOID)wszFilename, MAX_PATH);
327 psh.pszCaption = (LPCWSTR)wszFilename;
329 /* Find out where to look for the shell extensions */
330 if (_ILIsValue(This->apidl[0]))
334 if (_ILGetExtension(This->apidl[0], sTemp, 64))
336 HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE);
337 MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wszFiletype, MAX_PATH);
344 else if (_ILIsFolder(This->apidl[0]))
346 lstrcpynW(wszFiletype, wszFolder, 64);
348 else if (_ILIsSpecialFolder(This->apidl[0]))
351 static const WCHAR wszclsid[] = {'C','L','S','I','D','\\', 0};
352 folderGUID = _ILGetGUIDPointer(This->apidl[0]);
353 lstrcpyW(wszFiletype, wszclsid);
354 StringFromGUID2(folderGUID, &wszFiletype[6], MAX_PATH - 6);
358 FIXME("Requested properties for unknown type.\n");
362 /* Get a suitable DataObject for accessing the files */
363 SHGetDesktopFolder(&lpDesktopSF);
364 if (_ILIsPidlSimple(This->pidl))
366 ret = IShellFolder_GetUIObjectOf(lpDesktopSF, hwnd, This->cidl, (LPCITEMIDLIST*)This->apidl,
367 &IID_IDataObject, NULL, (LPVOID *)&lpDo);
368 IShellFolder_Release(lpDesktopSF);
372 IShellFolder_BindToObject(lpDesktopSF, This->pidl, NULL, &IID_IShellFolder, (LPVOID*) &lpSF);
373 ret = IShellFolder_GetUIObjectOf(lpSF, hwnd, This->cidl, (LPCITEMIDLIST*)This->apidl,
374 &IID_IDataObject, NULL, (LPVOID *)&lpDo);
375 IShellFolder_Release(lpSF);
376 IShellFolder_Release(lpDesktopSF);
381 hpsxa = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszFiletype, MAX_PROP_PAGES - psh.nPages, lpDo);
384 SHAddFromPropSheetExtArray(hpsxa, Properties_AddPropSheetCallback, (LPARAM)&psh);
385 SHDestroyPropSheetExtArray(hpsxa);
387 hpsxa = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, wszFiletypeAll, MAX_PROP_PAGES - psh.nPages, lpDo);
390 SHAddFromPropSheetExtArray(hpsxa, Properties_AddPropSheetCallback, (LPARAM)&psh);
391 SHDestroyPropSheetExtArray(hpsxa);
393 IDataObject_Release(lpDo);
397 PropertySheetW(&psh);
399 FIXME("No property pages found.\n");
402 static HRESULT WINAPI ItemMenu_InvokeCommand(
403 IContextMenu2 *iface,
404 LPCMINVOKECOMMANDINFO lpcmi)
406 ContextMenu *This = impl_from_IContextMenu2(iface);
408 if (lpcmi->cbSize != sizeof(CMINVOKECOMMANDINFO))
409 FIXME("Is an EX structure\n");
411 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);
413 if( HIWORD(lpcmi->lpVerb)==0 && LOWORD(lpcmi->lpVerb) > FCIDM_SHVIEWLAST)
415 TRACE("Invalid Verb %x\n",LOWORD(lpcmi->lpVerb));
419 if (HIWORD(lpcmi->lpVerb) == 0)
421 switch(LOWORD(lpcmi->lpVerb - This->verb_offset))
423 case FCIDM_SHVIEW_EXPLORE:
424 TRACE("Verb FCIDM_SHVIEW_EXPLORE\n");
425 DoOpenExplore(This, lpcmi->hwnd, "explore");
427 case FCIDM_SHVIEW_OPEN:
428 TRACE("Verb FCIDM_SHVIEW_OPEN\n");
429 DoOpenExplore(This, lpcmi->hwnd, "open");
431 case FCIDM_SHVIEW_RENAME:
433 IShellBrowser *browser;
435 /* get the active IShellView */
436 browser = (IShellBrowser*)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0);
441 if(SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
443 TRACE("(shellview=%p)\n", view);
444 IShellView_SelectItem(view, This->apidl[0],
445 SVSI_DESELECTOTHERS|SVSI_EDIT|SVSI_ENSUREVISIBLE|SVSI_FOCUSED|SVSI_SELECT);
446 IShellView_Release(view);
451 case FCIDM_SHVIEW_DELETE:
452 TRACE("Verb FCIDM_SHVIEW_DELETE\n");
455 case FCIDM_SHVIEW_COPY:
456 TRACE("Verb FCIDM_SHVIEW_COPY\n");
457 DoCopyOrCut(This, lpcmi->hwnd, FALSE);
459 case FCIDM_SHVIEW_CUT:
460 TRACE("Verb FCIDM_SHVIEW_CUT\n");
461 DoCopyOrCut(This, lpcmi->hwnd, TRUE);
463 case FCIDM_SHVIEW_PROPERTIES:
464 TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n");
465 DoOpenProperties(This, lpcmi->hwnd);
468 FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)-This->verb_offset);
474 TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb));
475 if (strcmp(lpcmi->lpVerb,"delete")==0)
477 else if (strcmp(lpcmi->lpVerb,"properties")==0)
478 DoOpenProperties(This, lpcmi->hwnd);
480 FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb));
487 static HRESULT WINAPI ItemMenu_GetCommandString(
488 IContextMenu2 *iface,
495 ContextMenu *This = impl_from_IContextMenu2(iface);
496 HRESULT hr = E_INVALIDARG;
498 TRACE("(%p)->(%lx flags=%x %p name=%p len=%x)\n", This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
508 switch(idCommand-This->verb_offset)
510 case FCIDM_SHVIEW_RENAME:
511 strcpy(lpszName, "rename");
517 /* NT 4.0 with IE 3.0x or no IE will always call This with GCS_VERBW. In This
518 case, you need to do the lstrcpyW to the pointer passed.*/
520 switch(idCommand-This->verb_offset)
522 case FCIDM_SHVIEW_RENAME:
523 MultiByteToWideChar( CP_ACP, 0, "rename", -1, (LPWSTR)lpszName, uMaxNameLen );
534 TRACE("-- (%p)->(name=%s)\n", This, lpszName);
538 /**************************************************************************
540 * should be only in IContextMenu2 and IContextMenu3
541 * is nevertheless called from word95
543 static HRESULT WINAPI ItemMenu_HandleMenuMsg(
544 IContextMenu2 *iface,
549 ContextMenu *This = impl_from_IContextMenu2(iface);
550 TRACE("(%p)->(0x%x 0x%lx 0x%lx)\n", This, uMsg, wParam, lParam);
554 static const IContextMenu2Vtbl ItemContextMenuVtbl =
556 ContextMenu_QueryInterface,
559 ItemMenu_QueryContextMenu,
560 ItemMenu_InvokeCommand,
561 ItemMenu_GetCommandString,
562 ItemMenu_HandleMenuMsg
565 IContextMenu2 *ItemMenu_Constructor(IShellFolder *parent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *apidl, UINT cidl)
570 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
571 This->IContextMenu2_iface.lpVtbl = &ItemContextMenuVtbl;
573 This->verb_offset = 0;
574 This->parent = parent;
575 if (parent) IShellFolder_AddRef(parent);
577 This->pidl = ILClone(pidl);
578 This->apidl = _ILCopyaPidl(apidl, cidl);
580 This->allvalues = TRUE;
582 This->desktop = FALSE;
584 for(u = 0; u < cidl; u++)
585 This->allvalues &= (_ILIsValue(apidl[u]) ? 1 : 0);
587 TRACE("(%p)\n", This);
589 return &This->IContextMenu2_iface;
592 /* Background menu implementation */
593 static HRESULT WINAPI BackgroundMenu_QueryContextMenu(
594 IContextMenu2 *iface,
601 ContextMenu *This = impl_from_IContextMenu2(iface);
606 TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",
607 This, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
609 This->verb_offset = idCmdFirst;
611 hMyMenu = LoadMenuA(shell32_hInstance, "MENU_002");
612 if (uFlags & CMF_DEFAULTONLY)
614 HMENU ourMenu = GetSubMenu(hMyMenu,0);
615 UINT oldDef = GetMenuDefaultItem(hMenu,TRUE,GMDI_USEDISABLED);
616 UINT newDef = GetMenuDefaultItem(ourMenu,TRUE,GMDI_USEDISABLED);
617 if (newDef != oldDef)
618 SetMenuDefaultItem(hMenu,newDef,TRUE);
619 if (newDef!=0xFFFFFFFF)
620 hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, newDef+1);
622 hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
626 idMax = Shell_MergeMenus (hMenu, GetSubMenu(hMyMenu,0), indexMenu,
627 idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
628 hr = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, idMax-idCmdFirst);
630 DestroyMenu(hMyMenu);
632 TRACE("(%p)->returning 0x%x\n",This,hr);
636 static void DoNewFolder(ContextMenu *This, IShellView *view)
640 IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&helper);
643 WCHAR nameW[MAX_PATH];
646 ISFHelper_GetUniqueName(helper, nameW, MAX_PATH);
647 ISFHelper_AddFolder(helper, 0, nameW, &pidl);
651 /* if we are in a shellview do labeledit */
652 IShellView_SelectItem(view,
653 pidl,(SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE
654 |SVSI_FOCUSED|SVSI_SELECT));
658 ISFHelper_Release(helper);
662 static BOOL DoPaste(ContextMenu *This)
664 BOOL bSuccess = FALSE;
669 if(SUCCEEDED(OleGetClipboard(&pda)))
674 TRACE("pda=%p\n", pda);
676 /* Set the FORMATETC structure*/
677 InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLISTW), TYMED_HGLOBAL);
679 /* Get the pidls from IDataObject */
680 if(SUCCEEDED(IDataObject_GetData(pda,&formatetc,&medium)))
682 LPITEMIDLIST * apidl;
684 IShellFolder *psfFrom = NULL, *psfDesktop;
686 LPIDA lpcida = GlobalLock(medium.u.hGlobal);
687 TRACE("cida=%p\n", lpcida);
689 apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
691 /* bind to the source shellfolder */
692 SHGetDesktopFolder(&psfDesktop);
695 IShellFolder_BindToObject(psfDesktop, pidl, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom);
696 IShellFolder_Release(psfDesktop);
701 /* get source and destination shellfolder */
702 ISFHelper *psfhlpdst, *psfhlpsrc;
703 IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&psfhlpdst);
704 IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (void**)&psfhlpsrc);
706 /* do the copy/move */
707 if (psfhlpdst && psfhlpsrc)
709 ISFHelper_CopyItems(psfhlpdst, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl);
711 ISFHelper_DeleteItems(psfhlpsrc, lpcida->cidl, apidl);
714 if(psfhlpdst) ISFHelper_Release(psfhlpdst);
715 if(psfhlpsrc) ISFHelper_Release(psfhlpsrc);
716 IShellFolder_Release(psfFrom);
719 _ILFreeaPidl(apidl, lpcida->cidl);
722 /* release the medium*/
723 ReleaseStgMedium(&medium);
725 IDataObject_Release(pda);
731 hMem = GetClipboardData(CF_HDROP);
735 char * pDropFiles = GlobalLock(hMem);
738 int len, offset = sizeof(DROPFILESTRUCT);
740 while( pDropFiles[offset] != 0)
742 len = strlen(pDropFiles + offset);
743 TRACE("%s\n", pDropFiles + offset);
754 static HRESULT WINAPI BackgroundMenu_InvokeCommand(
755 IContextMenu2 *iface,
756 LPCMINVOKECOMMANDINFO lpcmi)
758 ContextMenu *This = impl_from_IContextMenu2(iface);
759 IShellBrowser *browser;
760 IShellView *view = NULL;
763 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n", This, lpcmi, lpcmi->lpVerb, lpcmi->hwnd);
765 /* get the active IShellView */
766 if ((browser = (IShellBrowser*)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0)))
768 if (SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view)))
769 IShellView_GetWindow(view, &hWnd);
772 if(HIWORD(lpcmi->lpVerb))
774 TRACE("%s\n", debugstr_a(lpcmi->lpVerb));
776 if (!strcmp(lpcmi->lpVerb, CMDSTR_NEWFOLDERA))
778 DoNewFolder(This, view);
780 else if (!strcmp(lpcmi->lpVerb, CMDSTR_VIEWLISTA))
782 if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW, 0), 0);
784 else if (!strcmp(lpcmi->lpVerb, CMDSTR_VIEWDETAILSA))
786 if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW, 0), 0);
790 FIXME("please report: unknown verb %s\n", debugstr_a(lpcmi->lpVerb));
795 switch (LOWORD(lpcmi->lpVerb) - This->verb_offset)
797 case FCIDM_SHVIEW_REFRESH:
798 if (view) IShellView_Refresh(view);
801 case FCIDM_SHVIEW_NEWFOLDER:
802 DoNewFolder(This, view);
805 case FCIDM_SHVIEW_INSERT:
809 case FCIDM_SHVIEW_PROPERTIES:
811 ShellExecuteA(lpcmi->hwnd, "open", "rundll32.exe shell32.dll,Control_RunDLL desk.cpl", NULL, NULL, SW_SHOWNORMAL);
813 FIXME("launch item properties dialog\n");
818 /* if it's an id just pass it to the parent shv */
819 if (hWnd) SendMessageA(hWnd, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0), 0);
825 IShellView_Release(view);
830 static HRESULT WINAPI BackgroundMenu_GetCommandString(
831 IContextMenu2 *iface,
838 ContextMenu *This = impl_from_IContextMenu2(iface);
840 TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
842 /* test the existence of the menu items, the file dialog enables
843 the buttons according to this */
844 if (uFlags == GCS_VALIDATEA)
846 if(HIWORD(idCommand))
848 if (!strcmp((LPSTR)idCommand, CMDSTR_VIEWLISTA) ||
849 !strcmp((LPSTR)idCommand, CMDSTR_VIEWDETAILSA) ||
850 !strcmp((LPSTR)idCommand, CMDSTR_NEWFOLDERA))
857 FIXME("unknown command string\n");
861 static HRESULT WINAPI BackgroundMenu_HandleMenuMsg(
862 IContextMenu2 *iface,
867 ContextMenu *This = impl_from_IContextMenu2(iface);
868 FIXME("(%p)->(msg=%x wp=%lx lp=%lx)\n",This, uMsg, wParam, lParam);
872 static const IContextMenu2Vtbl BackgroundContextMenuVtbl =
874 ContextMenu_QueryInterface,
877 BackgroundMenu_QueryContextMenu,
878 BackgroundMenu_InvokeCommand,
879 BackgroundMenu_GetCommandString,
880 BackgroundMenu_HandleMenuMsg
883 IContextMenu2 *BackgroundMenu_Constructor(IShellFolder *parent, BOOL desktop)
887 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
888 This->IContextMenu2_iface.lpVtbl = &BackgroundContextMenuVtbl;
890 This->parent = parent;
891 This->verb_offset = 0;
896 This->allvalues = FALSE;
898 This->desktop = desktop;
899 if (parent) IShellFolder_AddRef(parent);
901 TRACE("(%p)\n", This);
902 return &This->IContextMenu2_iface;