3 * ShellView Background Context Menu (shv_bg_cm)
5 * Copyright 1999 Juergen Schmied <juergen.schmied@metronet.de>
10 #include "debugtools.h"
13 #include "wine/obj_base.h"
14 #include "wine/obj_contextmenu.h"
15 #include "wine/obj_shellbrowser.h"
16 #include "wine/obj_shellextinit.h"
18 #include "shell32_main.h"
20 DEFAULT_DEBUG_CHANNEL(shell)
22 /**************************************************************************
23 * IContextMenu Implementation
26 { ICOM_VFIELD(IContextMenu);
31 static struct ICOM_VTABLE(IContextMenu) cmvt;
33 /**************************************************************************
34 * ISVBgCm_Constructor()
36 IContextMenu *ISvBgCm_Constructor(void)
40 cm = (BgCmImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(BgCmImpl));
44 TRACE("(%p)->()\n",cm);
46 return (IContextMenu*)cm;
49 /**************************************************************************
50 * ISVBgCm_fnQueryInterface
52 static HRESULT WINAPI ISVBgCm_fnQueryInterface(IContextMenu *iface, REFIID riid, LPVOID *ppvObj)
54 ICOM_THIS(BgCmImpl, iface);
56 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
60 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
64 else if(IsEqualIID(riid, &IID_IContextMenu)) /*IContextMenu*/
68 else if(IsEqualIID(riid, &IID_IShellExtInit)) /*IShellExtInit*/
70 FIXME("-- LPSHELLEXTINIT pointer requested\n");
75 IUnknown_AddRef((IUnknown*)*ppvObj);
76 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
79 TRACE("-- Interface: E_NOINTERFACE\n");
83 /**************************************************************************
86 static ULONG WINAPI ISVBgCm_fnAddRef(IContextMenu *iface)
88 ICOM_THIS(BgCmImpl, iface);
90 TRACE("(%p)->(count=%lu)\n",This, This->ref);
96 /**************************************************************************
99 static ULONG WINAPI ISVBgCm_fnRelease(IContextMenu *iface)
101 ICOM_THIS(BgCmImpl, iface);
103 TRACE("(%p)->()\n",This);
108 { TRACE(" destroying IContextMenu(%p)\n",This);
110 HeapFree(GetProcessHeap(),0,This);
116 /**************************************************************************
117 * ISVBgCm_fnQueryContextMenu()
120 static HRESULT WINAPI ISVBgCm_fnQueryContextMenu(
131 ICOM_THIS(BgCmImpl, iface);
133 TRACE("(%p)->(hmenu=%x indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",This, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
135 hMyMenu = LoadMenuA(shell32_hInstance, "MENU_002");
137 idMax = Shell_MergeMenus (hMenu, GetSubMenu(hMyMenu,0), indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
139 DestroyMenu(hMyMenu);
141 return ResultFromShort(idMax - idCmdFirst);
144 /**************************************************************************
145 * ISVBgCm_fnInvokeCommand()
147 static HRESULT WINAPI ISVBgCm_fnInvokeCommand(
149 LPCMINVOKECOMMANDINFO lpcmi)
151 ICOM_THIS(BgCmImpl, iface);
157 TRACE("(%p)->(invcom=%p verb=%p wnd=%x)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd);
159 /* get the active IShellView */
160 lpSB = (LPSHELLBROWSER)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER,0,0);
161 IShellBrowser_QueryActiveShellView(lpSB, &lpSV);
162 IShellView_GetWindow(lpSV, &hWndSV);
164 if(HIWORD(lpcmi->lpVerb))
166 TRACE("%s\n",lpcmi->lpVerb);
168 if (! strcmp(lpcmi->lpVerb,CMDSTR_NEWFOLDERA))
170 FIXME("%s not implemented\n",lpcmi->lpVerb);
172 else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWLISTA))
174 SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_LISTVIEW,0),0 );
176 else if (! strcmp(lpcmi->lpVerb,CMDSTR_VIEWDETAILSA))
178 SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(FCIDM_SHVIEW_REPORTVIEW,0),0 );
182 FIXME("please report: unknown verb %s\n",lpcmi->lpVerb);
187 /* if it's a id just pass it to the parent shv */
188 SendMessageA(hWndSV, WM_COMMAND, MAKEWPARAM(LOWORD(lpcmi->lpVerb), 0),0 );
191 IShellView_Release(lpSV); /* QueryActiveShellView does AddRef*/
195 /**************************************************************************
196 * ISVBgCm_fnGetCommandString()
199 static HRESULT WINAPI ISVBgCm_fnGetCommandString(
207 ICOM_THIS(BgCmImpl, iface);
209 TRACE("(%p)->(idcom=%x flags=%x %p name=%p len=%x)\n",This, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
211 /* test the existance of the menu items, the file dialog enables
212 the buttons according to this */
213 if (uFlags == GCS_VALIDATEA)
215 if(HIWORD(idCommand))
217 if (!strcmp((LPSTR)idCommand, CMDSTR_VIEWLISTA) ||
218 !strcmp((LPSTR)idCommand, CMDSTR_VIEWDETAILSA) ||
219 !strcmp((LPSTR)idCommand, CMDSTR_NEWFOLDERA))
226 FIXME("unknown command string\n");
230 /**************************************************************************
231 * ISVBgCm_fnHandleMenuMsg()
233 static HRESULT WINAPI ISVBgCm_fnHandleMenuMsg(
239 ICOM_THIS(BgCmImpl, iface);
241 FIXME("(%p)->(msg=%x wp=%x lp=%lx)\n",This, uMsg, wParam, lParam);
246 /**************************************************************************
247 * IContextMenu VTable
250 static struct ICOM_VTABLE(IContextMenu) cmvt =
252 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
253 ISVBgCm_fnQueryInterface,
256 ISVBgCm_fnQueryContextMenu,
257 ISVBgCm_fnInvokeCommand,
258 ISVBgCm_fnGetCommandString,
259 ISVBgCm_fnHandleMenuMsg,
260 (void *) 0xdeadbabe /* just paranoia (IContextMenu3) */