ReactOS  0.4.15-dev-5487-ge7bbbf0
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 
46  if (ppid)
47  *ppid = NULL;
48 
49  return E_NOTIMPL;
50 }
51 
53 {
54  TRACE("(%p, %p)\n", this, ppid);
55 
56  if (ppid)
57  *ppid = NULL;
58 
59  return E_NOTIMPL;
60 }
61 
63 {
64  if (!pbs)
65  return E_POINTER;
66  *pbs = SysAllocString(m_name);
67  return S_OK;
68 }
69 
71 {
72  TRACE("(%p, %p)\n", this);
73  return E_NOTIMPL;
74 }
75 
76 
77 
78 
79 
80 
82  :m_menu(NULL)
83  ,m_count(0)
84 {
85 }
86 
88 {
90 }
91 
93 {
98  return hr;
99 
100  hr = folder->GetUIObjectOf(NULL, 1, &child, IID_IContextMenu, NULL, (PVOID*)&m_contextmenu);
101  if (FAILED_UNEXPECTEDLY(hr))
102  return hr;
103 
105  hr = m_contextmenu->QueryContextMenu(m_menu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
106  if (!SUCCEEDED(hr))
107  return hr;
108 
110  return hr;
111 }
112 
113 
114 // *** FolderItemVerbs methods ***
116 {
117  if (!plCount)
118  return E_INVALIDARG;
119  *plCount = m_count;
120  return S_OK;
121 }
122 
124 {
125  TRACE("(%p, %p)\n", this, ppid);
126 
127  if (ppid)
128  *ppid = NULL;
129 
130  return E_NOTIMPL;
131 }
132 
134 {
135  TRACE("(%p, %p)\n", this, ppid);
136 
137  if (ppid)
138  *ppid = NULL;
139 
140  return E_NOTIMPL;
141 }
142 
143 HRESULT STDMETHODCALLTYPE CFolderItemVerbs::Item(VARIANT indexVar, FolderItemVerb **ppid)
144 {
145  if (!ppid)
146  return E_POINTER;
147 
149 
150  HRESULT hr = VariantChangeType(&var, &indexVar, 0, VT_I4);
151  if (FAILED_UNEXPECTEDLY(hr))
152  return E_INVALIDARG;
153 
154  int index = V_I4(&var);
155 
156  if (index > m_count)
157  return S_OK;
158 
159  BSTR name = NULL;
160 
161  if(index == m_count)
162  {
164  }
165  else
166  {
167  MENUITEMINFOW info = { sizeof(info), 0 };
168  info.fMask = MIIM_STRING;
170  return E_FAIL;
172  if (name)
173  {
174  info.dwTypeData = name;
175  info.cch++;
177  }
178  }
179 
180  if (!name)
181  return E_OUTOFMEMORY;
182 
184  verb->Init(m_contextmenu, name);
185  verb->AddRef();
186  *ppid = verb;
187 
188  return S_OK;
189 }
190 
192 {
193  TRACE("(%p, %p)\n", this, ppunk);
194  return E_NOTIMPL;
195 }
196 
197 
const char * var
Definition: shader.c:5666
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:962
virtual HRESULT STDMETHODCALLTYPE get_Count(LONG *plCount)
Definition: compat.h:2298
Definition: fci.c:115
HRESULT hr
Definition: shlfolder.c:183
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
virtual ~CFolderItemVerbs()
virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid)
#define TRUE
Definition: types.h:120
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define FCIDM_SHVIEWFIRST
Definition: shlobj.h:507
virtual HRESULT STDMETHODCALLTYPE Item(VARIANT index, FolderItemVerb **ppid)
OLECHAR * BSTR
Definition: compat.h:2293
#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
virtual HRESULT STDMETHODCALLTYPE _NewEnum(IUnknown **ppunk)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
static struct _test_info info[]
Definition: SetCursorPos.c:19
if SUCCEEDED(hr)
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
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
GLuint index
Definition: glext.h:6031
struct CFFOLDER folder
Definition: fdi.c:102
#define FCIDM_SHVIEWLAST
Definition: shlobj.h:541
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
#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:52
CComPtr< IContextMenu > m_contextmenu
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1337
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define E_NOTIMPL
Definition: ddrawi.h:99
virtual HRESULT STDMETHODCALLTYPE DoIt()
#define NULL
Definition: types.h:112
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
Definition: name.c:38
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
GLuint const GLchar * name
Definition: glext.h:6031