ReactOS  0.4.14-dev-49-gfb4591c
CFolderItemVerbs.cpp
Go to the documentation of this file.
1 /*
2  * FolderItemVerb(s) implementation
3  *
4  * Copyright 2015 Mark Jansen
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #include "precomp.h"
22 
24 
25 
27 {
28 }
29 
31 {
32 }
33 
35 {
36  m_contextmenu = menu;
37  m_name.m_str = name;
38 }
39 
40 // *** FolderItemVerb methods ***
41 
43 {
44  TRACE("(%p, %p)\n", this, ppid);
45  return E_NOTIMPL;
46 }
47 
49 {
50  TRACE("(%p, %p)\n", this, ppid);
51  return E_NOTIMPL;
52 }
53 
55 {
56  if (!pbs)
57  return E_POINTER;
58  *pbs = SysAllocString(m_name);
59  return S_OK;
60 }
61 
63 {
64  TRACE("(%p, %p)\n", this);
65  return E_NOTIMPL;
66 }
67 
68 
69 
70 
71 
72 
74  :m_menu(NULL)
75  ,m_count(0)
76 {
77 }
78 
80 {
82 }
83 
85 {
90  return hr;
91 
92  hr = folder->GetUIObjectOf(NULL, 1, &child, IID_IContextMenu, NULL, (PVOID*)&m_contextmenu);
94  return hr;
95 
97  hr = m_contextmenu->QueryContextMenu(m_menu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
98  if (!SUCCEEDED(hr))
99  return hr;
100 
102  return hr;
103 }
104 
105 
106 // *** FolderItemVerbs methods ***
108 {
109  if (!plCount)
110  return E_INVALIDARG;
111  *plCount = m_count;
112  return S_OK;
113 }
114 
116 {
117  TRACE("(%p, %p)\n", this, ppid);
118 
119  if (ppid)
120  *ppid = NULL;
121 
122  return E_NOTIMPL;
123 }
124 
126 {
127  TRACE("(%p, %p)\n", this, ppid);
128 
129  if (ppid)
130  *ppid = NULL;
131 
132  return E_NOTIMPL;
133 }
134 
135 HRESULT STDMETHODCALLTYPE CFolderItemVerbs::Item(VARIANT indexVar, FolderItemVerb **ppid)
136 {
137  if (!ppid)
138  return E_POINTER;
139 
140  CComVariant var;
141 
142  HRESULT hr = VariantChangeType(&var, &indexVar, 0, VT_I4);
143  if (FAILED_UNEXPECTEDLY(hr))
144  return E_INVALIDARG;
145 
146  int index = V_I4(&var);
147 
148  if (index > m_count)
149  return S_OK;
150 
151  BSTR name = NULL;
152 
153  if(index == m_count)
154  {
156  }
157  else
158  {
159  MENUITEMINFOW info = { sizeof(info), 0 };
160  info.fMask = MIIM_STRING;
162  return E_FAIL;
164  if (name)
165  {
166  info.dwTypeData = name;
167  info.cch++;
169  }
170  }
171 
172  if (!name)
173  return E_OUTOFMEMORY;
174 
176  verb->Init(m_contextmenu, name);
177  verb->AddRef();
178  *ppid = verb;
179 
180  return S_OK;
181 }
182 
184 {
185  TRACE("(%p, %p)\n", this, ppunk);
186  return E_NOTIMPL;
187 }
188 
189 
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:965
#define TRUE
Definition: types.h:120
virtual HRESULT STDMETHODCALLTYPE get_Count(LONG *plCount)
Definition: compat.h:1939
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
virtual ~CFolderItemVerbs()
virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid)
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define FCIDM_SHVIEWFIRST
Definition: shlobj.h:499
virtual HRESULT STDMETHODCALLTYPE Item(VARIANT index, FolderItemVerb **ppid)
OLECHAR * BSTR
Definition: compat.h:1934
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid)
static HWND child
Definition: cursoricon.c:298
#define V_I4(A)
Definition: oleauto.h:247
CComPtr< IContextMenu > m_contextmenu
struct _test_info info[]
Definition: SetCursorPos.c:19
virtual HRESULT STDMETHODCALLTYPE _NewEnum(IUnknown **ppunk)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppid)
WINE_DEFAULT_DEBUG_CHANNEL(shell)
void Init(IContextMenu *menu, BSTR name)
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
GLuint index
Definition: glext.h:6031
struct CFFOLDER folder
Definition: fdi.c:110
#define FCIDM_SHVIEWLAST
Definition: shlobj.h:532
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
virtual HRESULT STDMETHODCALLTYPE get_Name(BSTR *pbs)
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define MIIM_STRING
Definition: winuser.h:722
#define S_OK
Definition: intsafe.h:59
CComPtr< IContextMenu > m_contextmenu
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define E_NOTIMPL
Definition: ddrawi.h:99
virtual HRESULT STDMETHODCALLTYPE DoIt()
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
Definition: name.c:36
HRESULT Init(LPITEMIDLIST idlist)
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppid)
#define E_POINTER
Definition: winerror.h:2365
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57
GLuint const GLchar * name
Definition: glext.h:6031