ReactOS 0.4.15-dev-8102-g108db8f
CSendToMenu Class Reference

#include <CSendToMenu.h>

Inheritance diagram for CSendToMenu:
Collaboration diagram for CSendToMenu:

Classes

struct  SENDTO_ITEM
 

Public Member Functions

 CSendToMenu ()
 
 ~CSendToMenu ()
 
STDMETHODIMP QueryContextMenu (HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
STDMETHODIMP InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
 
STDMETHODIMP GetCommandString (UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen)
 
STDMETHODIMP HandleMenuMsg2 (UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
 
STDMETHODIMP HandleMenuMsg (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
STDMETHODIMP Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
HRESULT HandleMenuMsg2 ([in] UINT uMsg, [in] WPARAM wParam, [in] LPARAM lParam, [out] LRESULT *plResult)
 
HRESULT HandleMenuMsg ([in] UINT uMsg, [in] WPARAM wParam, [in] LPARAM lParam)
 
HRESULT QueryContextMenu ([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
 
HRESULT InvokeCommand ([in] LPCMINVOKECOMMANDINFO lpici)
 
HRESULT GetCommandString ([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
HRESULT Initialize ([in] PCIDLIST_ABSOLUTE pidlFolder, [in] IDataObject *pdtobj, [in] HKEY hkeyProgID)
 

Private Member Functions

HRESULT LoadAllItems (HWND hwnd)
 
void UnloadAllItems ()
 
UINT InsertSendToItems (HMENU hMenu, UINT idFirst, UINT idMenu)
 
SENDTO_ITEMFindItemFromIdOffset (UINT IdOffset)
 
HRESULT DoSendToItem (SENDTO_ITEM *pItem, LPCMINVOKECOMMANDINFO lpici)
 
HRESULT DoDrop (IDataObject *pDataObject, IDropTarget *pDropTarget)
 
HRESULT GetSpecialFolder (HWND hwnd, IShellFolder **ppFolder, int csidl, PIDLIST_ABSOLUTE *ppidl=NULL)
 
HRESULT GetUIObjectFromPidl (HWND hwnd, PIDLIST_ABSOLUTE pidl, REFIID riid, LPVOID *ppvOut)
 

Private Attributes

HMENU m_hSubMenu
 
SENDTO_ITEMm_pItems
 
UINT m_idCmdFirst
 
CComPtr< IShellFolderm_pDesktop
 
CComPtr< IShellFolderm_pSendTo
 
CComPtr< IDataObjectm_pDataObject
 

Additional Inherited Members

- Public Types inherited from IContextMenu3
typedef IContextMenu3LPCONTEXTMENU3
 
- Public Types inherited from IContextMenu2
typedef IContextMenu2LPCONTEXTMENU2
 
- Public Types inherited from IContextMenu
typedef IContextMenuLPCONTEXTMENU
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IShellExtInit
typedef IShellExtInitLPSHELLEXTINIT
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Static Public Attributes inherited from IContextMenu
static const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 26 of file CSendToMenu.h.

Constructor & Destructor Documentation

◆ CSendToMenu()

CSendToMenu::CSendToMenu ( )

Definition at line 25 of file CSendToMenu.cpp.

27 , m_pItems(NULL)
28 , m_idCmdFirst(0)
29{
31 if (FAILED(hr))
32 {
33 ERR("SHGetDesktopFolder: %08lX\n", hr);
34 }
35
37}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define ERR(fmt,...)
Definition: debug.h:113
SENDTO_ITEM * m_pItems
Definition: CSendToMenu.h:62
CComPtr< IShellFolder > m_pSendTo
Definition: CSendToMenu.h:66
CComPtr< IShellFolder > m_pDesktop
Definition: CSendToMenu.h:65
HRESULT GetSpecialFolder(HWND hwnd, IShellFolder **ppFolder, int csidl, PIDLIST_ABSOLUTE *ppidl=NULL)
HMENU m_hSubMenu
Definition: CSendToMenu.h:61
UINT m_idCmdFirst
Definition: CSendToMenu.h:63
#define NULL
Definition: types.h:112
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_SENDTO
Definition: shlobj.h:2168

◆ ~CSendToMenu()

CSendToMenu::~CSendToMenu ( )

Definition at line 39 of file CSendToMenu.cpp.

40{
42
43 if (m_hSubMenu)
44 {
47 }
48}
void UnloadAllItems()
BOOL WINAPI DestroyMenu(_In_ HMENU)

Member Function Documentation

◆ DoDrop()

HRESULT CSendToMenu::DoDrop ( IDataObject pDataObject,
IDropTarget pDropTarget 
)
private

Definition at line 50 of file CSendToMenu.cpp.

51{
52 DWORD dwEffect = DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK;
53
54 BOOL bShift = (GetAsyncKeyState(VK_SHIFT) < 0);
55 BOOL bCtrl = (GetAsyncKeyState(VK_CONTROL) < 0);
56
57 // THIS CODE IS NOT HUMAN-FRIENDLY. SORRY.
58 // (We have to translate a SendTo action to a Drop action)
59 DWORD dwKeyState = MK_LBUTTON;
60 if (bShift && bCtrl)
61 dwKeyState |= MK_SHIFT | MK_CONTROL;
62 else if (!bShift)
63 dwKeyState |= MK_CONTROL;
64 if (bCtrl)
65 dwKeyState |= MK_SHIFT;
66
67 POINTL ptl = { 0, 0 };
68 HRESULT hr = pDropTarget->DragEnter(pDataObject, dwKeyState, ptl, &dwEffect);
70 {
71 pDropTarget->DragLeave();
72 return hr;
73 }
74
75 if (dwEffect == DROPEFFECT_NONE)
76 {
77 ERR("DROPEFFECT_NONE\n");
78 pDropTarget->DragLeave();
79 return E_FAIL;
80 }
81
82 // THIS CODE IS NOT HUMAN-FRIENDLY. SORRY.
83 // (We have to translate a SendTo action to a Drop action)
84 if (bShift && bCtrl)
85 dwEffect = DROPEFFECT_LINK;
86 else if (!bShift)
87 dwEffect = DROPEFFECT_MOVE;
88 else
89 dwEffect = DROPEFFECT_COPY;
90
91 hr = pDropTarget->Drop(pDataObject, dwKeyState, ptl, &dwEffect);
93 return hr;
94
95 return hr;
96}
#define E_FAIL
Definition: ddrawi.h:102
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT Drop([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
HRESULT DragLeave()
HRESULT DragEnter([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
#define MK_SHIFT
Definition: winuser.h:2369
#define VK_CONTROL
Definition: winuser.h:2203
#define MK_CONTROL
Definition: winuser.h:2370
#define MK_LBUTTON
Definition: winuser.h:2367
#define VK_SHIFT
Definition: winuser.h:2202
SHORT WINAPI GetAsyncKeyState(_In_ int)

Referenced by DoSendToItem().

◆ DoSendToItem()

HRESULT CSendToMenu::DoSendToItem ( SENDTO_ITEM pItem,
LPCMINVOKECOMMANDINFO  lpici 
)
private

Definition at line 266 of file CSendToMenu.cpp.

267{
268 if (!m_pDataObject)
269 {
270 ERR("!m_pDataObject\n");
271 return E_FAIL;
272 }
273
274 HRESULT hr;
275 CComPtr<IDropTarget> pDropTarget;
276 hr = m_pSendTo->GetUIObjectOf(NULL, 1, &pItem->pidlChild, IID_IDropTarget,
277 NULL, (LPVOID *)&pDropTarget);
279 return hr;
280
281 hr = DoDrop(m_pDataObject, pDropTarget);
283 return hr;
284
285 return hr;
286}
HRESULT DoDrop(IDataObject *pDataObject, IDropTarget *pDropTarget)
Definition: CSendToMenu.cpp:50
CComPtr< IDataObject > m_pDataObject
Definition: CSendToMenu.h:67

Referenced by InvokeCommand().

◆ FindItemFromIdOffset()

CSendToMenu::SENDTO_ITEM * CSendToMenu::FindItemFromIdOffset ( UINT  IdOffset)
private

Definition at line 253 of file CSendToMenu.cpp.

254{
255 UINT idCmd = m_idCmdFirst + IdOffset;
256
257 MENUITEMINFOW mii = { sizeof(mii) };
258 mii.fMask = MIIM_DATA;
259 if (GetMenuItemInfoW(m_hSubMenu, idCmd, FALSE, &mii))
260 return reinterpret_cast<SENDTO_ITEM *>(mii.dwItemData);
261
262 ERR("GetMenuItemInfoW: %ld\n", GetLastError());
263 return NULL;
264}
#define FALSE
Definition: types.h:117
unsigned int UINT
Definition: ndis.h:50
ULONG_PTR dwItemData
Definition: winuser.h:3268
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define MIIM_DATA
Definition: winuser.h:726

Referenced by InvokeCommand().

◆ GetCommandString()

STDMETHODIMP CSendToMenu::GetCommandString ( UINT_PTR  idCommand,
UINT  uFlags,
UINT lpReserved,
LPSTR  lpszName,
UINT  uMaxNameLen 
)

Implements IContextMenu.

Definition at line 352 of file CSendToMenu.cpp.

357{
358 FIXME("%p %lu %u %p %p %u\n", this,
359 idCmd, uType, pwReserved, pszName, cchMax);
360
361 return E_NOTIMPL;
362}
UINT cchMax
#define FIXME(fmt,...)
Definition: debug.h:114
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetSpecialFolder()

HRESULT CSendToMenu::GetSpecialFolder ( HWND  hwnd,
IShellFolder **  ppFolder,
int  csidl,
PIDLIST_ABSOLUTE ppidl = NULL 
)
private

Definition at line 100 of file CSendToMenu.cpp.

102{
103 if (!ppFolder)
104 return E_POINTER;
105 *ppFolder = NULL;
106
107 if (ppidl)
108 *ppidl = NULL;
109
111 HRESULT hr = SHGetSpecialFolderLocation(hwnd, csidl, &pidl);
113 return hr;
114
115 IShellFolder *pFolder = NULL;
116 hr = m_pDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &pFolder));
117
118 if (ppidl)
119 *ppidl = pidl.Detach();
120
122 return hr;
123
124 *ppFolder = pFolder;
125 return hr;
126}
T * Detach()
Definition: atlalloc.h:168
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3225
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define E_POINTER
Definition: winerror.h:2365
#define IID_PPV_ARG(Itype, ppType)

Referenced by CSendToMenu(), and LoadAllItems().

◆ GetUIObjectFromPidl()

HRESULT CSendToMenu::GetUIObjectFromPidl ( HWND  hwnd,
PIDLIST_ABSOLUTE  pidl,
REFIID  riid,
LPVOID ppvOut 
)
private

Definition at line 129 of file CSendToMenu.cpp.

131{
132 *ppvOut = NULL;
133
134 PCITEMID_CHILD pidlLast;
135 CComPtr<IShellFolder> pFolder;
136 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &pFolder), &pidlLast);
138 return hr;
139
140 hr = pFolder->GetUIObjectOf(hwnd, 1, &pidlLast, riid, NULL, ppvOut);
142 return hr;
143
144 return hr;
145}
REFIID riid
Definition: atlbase.h:39
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1348

◆ HandleMenuMsg()

STDMETHODIMP CSendToMenu::HandleMenuMsg ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Implements IContextMenu2.

Definition at line 365 of file CSendToMenu.cpp.

366{
367 return S_OK;
368}
#define S_OK
Definition: intsafe.h:52

◆ HandleMenuMsg2()

STDMETHODIMP CSendToMenu::HandleMenuMsg2 ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT plResult 
)

Implements IContextMenu3.

Definition at line 371 of file CSendToMenu.cpp.

373{
376
377 switch (uMsg)
378 {
379 case WM_MEASUREITEM:
380 {
381 MEASUREITEMSTRUCT* lpmis = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
382 if (!lpmis || lpmis->CtlType != ODT_MENU)
383 break;
384
385 UINT cxMenuCheck = GetSystemMetrics(SM_CXMENUCHECK);
386 if (lpmis->itemWidth < cxMenuCheck)
387 lpmis->itemWidth = cxMenuCheck;
388 if (lpmis->itemHeight < cySmall)
389 lpmis->itemHeight = cySmall;
390
391 if (plResult)
392 *plResult = TRUE;
393 break;
394 }
395 case WM_DRAWITEM:
396 {
397 DRAWITEMSTRUCT* lpdis = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
398 if (!lpdis || lpdis->CtlType != ODT_MENU)
399 break;
400
401 SENDTO_ITEM *pItem = reinterpret_cast<SENDTO_ITEM *>(lpdis->itemData);
402 HICON hIcon = NULL;
403 if (pItem)
404 hIcon = pItem->hIcon;
405 if (!hIcon)
406 break;
407
408 const RECT& rcItem = lpdis->rcItem;
409 INT x = 4;
410 INT y = lpdis->rcItem.top;
411 y += (rcItem.bottom - rcItem.top - cySmall) / 2;
412 DrawIconEx(lpdis->hDC, x, y, hIcon, cxSmall, cySmall,
413 0, NULL, DI_NORMAL);
414
415 if (plResult)
416 *plResult = TRUE;
417 }
418 }
419
420 return S_OK;
421}
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
ULONG_PTR itemData
Definition: winuser.h:3093
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
int32_t INT
Definition: typedefs.h:58
#define DI_NORMAL
Definition: wingdi.h:72
#define SM_CXMENUCHECK
Definition: winuser.h:1031
#define SM_CYSMICON
Definition: winuser.h:1013
#define WM_DRAWITEM
Definition: winuser.h:1645
#define SM_CXSMICON
Definition: winuser.h:1012
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2059
#define WM_MEASUREITEM
Definition: winuser.h:1646
#define ODT_MENU
Definition: winuser.h:2537
int WINAPI GetSystemMetrics(_In_ int)

◆ Initialize()

STDMETHODIMP CSendToMenu::Initialize ( PCIDLIST_ABSOLUTE  pidlFolder,
IDataObject pdtobj,
HKEY  hkeyProgID 
)

Implements IShellExtInit.

Definition at line 424 of file CSendToMenu.cpp.

426{
427 m_pDataObject = pdtobj;
428 return S_OK;
429}

◆ InsertSendToItems()

UINT CSendToMenu::InsertSendToItems ( HMENU  hMenu,
UINT  idFirst,
UINT  idMenu 
)
private

Definition at line 214 of file CSendToMenu.cpp.

215{
216 if (m_pItems == NULL)
217 {
220 return 0;
221 }
222
223 m_idCmdFirst = idCmdFirst;
224
225 UINT idCmd = idCmdFirst;
226 for (SENDTO_ITEM *pCurItem = m_pItems; pCurItem; pCurItem = pCurItem->pNext)
227 {
229 if (InsertMenuW(hMenu, Pos, uFlags, idCmd, pCurItem->pszText))
230 {
231 MENUITEMINFOW mii;
232 mii.cbSize = sizeof(mii);
234 mii.dwItemData = reinterpret_cast<ULONG_PTR>(pCurItem);
235 mii.hbmpItem = HBMMENU_CALLBACK;
236 SetMenuItemInfoW(hMenu, idCmd, FALSE, &mii);
237 ++idCmd;
238
239 // successful
240 }
241 }
242
243 if (idCmd == idCmdFirst)
244 {
246 AppendMenuW(hMenu, MF_GRAYED | MF_DISABLED | MF_STRING, idCmd, strNone);
247 ++idCmd;
248 }
249
250 return idCmd - idCmdFirst;
251}
#define IDS_NONE
Definition: resource.h:133
HRESULT LoadAllItems(HWND hwnd)
ush Pos
Definition: deflate.h:92
UINT uFlags
Definition: api.c:59
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOL WINAPI InsertMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define MF_STRING
Definition: winuser.h:138
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define MF_ENABLED
Definition: winuser.h:128
#define MIIM_BITMAP
Definition: winuser.h:728
#define MF_BYPOSITION
Definition: winuser.h:203
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define HBMMENU_CALLBACK
Definition: winuser.h:2630
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define MF_GRAYED
Definition: winuser.h:129
#define MF_DISABLED
Definition: winuser.h:130

Referenced by QueryContextMenu().

◆ InvokeCommand()

STDMETHODIMP CSendToMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)

Implements IContextMenu.

Definition at line 334 of file CSendToMenu.cpp.

335{
336 HRESULT hr = E_FAIL;
337
338 WORD idCmd = LOWORD(lpici->lpVerb);
339 TRACE("idCmd: %d\n", idCmd);
340
341 SENDTO_ITEM *pItem = FindItemFromIdOffset(idCmd);
342 if (pItem)
343 {
344 hr = DoSendToItem(pItem, lpici);
345 }
346
347 TRACE("CSendToMenu::InvokeCommand %x\n", hr);
348 return hr;
349}
SENDTO_ITEM * FindItemFromIdOffset(UINT IdOffset)
HRESULT DoSendToItem(SENDTO_ITEM *pItem, LPCMINVOKECOMMANDINFO lpici)
unsigned short WORD
Definition: ntddk_ex.h:93
#define LOWORD(l)
Definition: pedump.c:82
#define TRACE(s)
Definition: solgame.cpp:4

◆ LoadAllItems()

HRESULT CSendToMenu::LoadAllItems ( HWND  hwnd)
private

Definition at line 159 of file CSendToMenu.cpp.

160{
162
164
168 return hr;
169
170 CComPtr<IEnumIDList> pEnumIDList;
171 hr = m_pSendTo->EnumObjects(hwnd,
172 SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
173 &pEnumIDList);
175 return hr;
176
177 hr = S_OK;
179 while (pEnumIDList->Next(1, &child, NULL) == S_OK)
180 {
182
183 STRRET strret;
184 hr = m_pSendTo->GetDisplayNameOf(pidlChild, SHGDN_NORMAL, &strret);
186 continue;
187
188 CComHeapPtr<WCHAR> pszText;
189 hr = StrRetToStrW(&strret, pidlChild, &pszText);
191 continue;
192
194 pidlAbsolute.Attach(ILCombine(pidlSendTo, pidlChild));
195
196 SHFILEINFOW fi = { NULL };
199 SHGetFileInfoW(reinterpret_cast<LPWSTR>(static_cast<PIDLIST_ABSOLUTE>(pidlAbsolute)), 0,
200 &fi, sizeof(fi), uFlags);
201
202 SENDTO_ITEM *pNewItem =
203 new SENDTO_ITEM(pidlChild.Detach(), pszText.Detach(), fi.hIcon);
204 if (m_pItems)
205 {
206 pNewItem->pNext = m_pItems;
207 }
208 m_pItems = pNewItem;
209 }
210
211 return hr;
212}
void Release()
Definition: atlcomcli.h:170
void Attach(T *lp)
Definition: atlalloc.h:162
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1631
static HWND child
Definition: cursoricon.c:298
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:712
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:415
#define SHGFI_ICON
Definition: shellapi.h:164
#define SHGFI_TYPENAME
Definition: shellapi.h:167
#define SHGFI_SMALLICON
Definition: shellapi.h:176
#define SHGFI_PIDL
Definition: shellapi.h:180
HICON hIcon
Definition: shellapi.h:372
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by InsertSendToItems().

◆ QueryContextMenu()

STDMETHODIMP CSendToMenu::QueryContextMenu ( HMENU  hMenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)

Implements IContextMenu.

Definition at line 289 of file CSendToMenu.cpp.

294{
295 TRACE("%p %p %u %u %u %u\n", this,
296 hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
297
298 if (uFlags & (CMF_NOVERBS | CMF_VERBSONLY))
299 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, idCmdFirst);
300
301 HMENU hSubMenu = CreateMenu();
302 if (!hSubMenu)
303 {
304 ERR("CreateMenu: %ld\n", GetLastError());
305 return E_FAIL;
306 }
307
308 UINT cItems = InsertSendToItems(hSubMenu, idCmdFirst, 0);
309
311
312 MENUITEMINFOW mii = { sizeof(mii) };
314 mii.fType = MFT_STRING;
315 mii.wID = -1;
316 mii.dwTypeData = strSendTo.GetBuffer();
317 mii.cch = wcslen(mii.dwTypeData);
318 mii.fState = MFS_ENABLED;
319 mii.hSubMenu = hSubMenu;
320 if (!InsertMenuItemW(hMenu, indexMenu, TRUE, &mii))
321 {
322 ERR("InsertMenuItemW: %ld\n", GetLastError());
323 return E_FAIL;
324 }
325
326 HMENU hOldSubMenu = m_hSubMenu;
327 m_hSubMenu = hSubMenu;
328 DestroyMenu(hOldSubMenu);
329
330 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, idCmdFirst + cItems);
331}
UINT InsertSendToItems(HMENU hMenu, UINT idFirst, UINT idMenu)
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define IDS_SENDTO_MENU
Definition: shresdef.h:247
LPWSTR dwTypeData
Definition: winuser.h:3269
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MIIM_ID
Definition: winuser.h:722
HMENU WINAPI CreateMenu(void)
Definition: menu.c:829
#define MIIM_STATE
Definition: winuser.h:721
#define MIIM_SUBMENU
Definition: winuser.h:723
#define MFS_ENABLED
Definition: winuser.h:750
#define MFT_STRING
Definition: winuser.h:746
#define MIIM_TYPE
Definition: winuser.h:725
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ UnloadAllItems()

void CSendToMenu::UnloadAllItems ( )
private

Definition at line 147 of file CSendToMenu.cpp.

148{
149 SENDTO_ITEM *pItems = m_pItems;
150 m_pItems = NULL;
151 while (pItems)
152 {
153 SENDTO_ITEM *pCurItem = pItems;
154 pItems = pItems->pNext;
155 delete pCurItem;
156 }
157}
static int int const SCRIPT_CONTROL const SCRIPT_STATE SCRIPT_ITEM * pItems
Definition: usp10.c:62

Referenced by LoadAllItems(), and ~CSendToMenu().

Member Data Documentation

◆ m_hSubMenu

HMENU CSendToMenu::m_hSubMenu
private

Definition at line 61 of file CSendToMenu.h.

Referenced by FindItemFromIdOffset(), QueryContextMenu(), and ~CSendToMenu().

◆ m_idCmdFirst

UINT CSendToMenu::m_idCmdFirst
private

Definition at line 63 of file CSendToMenu.h.

Referenced by FindItemFromIdOffset(), and InsertSendToItems().

◆ m_pDataObject

CComPtr<IDataObject> CSendToMenu::m_pDataObject
private

Definition at line 67 of file CSendToMenu.h.

Referenced by DoSendToItem(), and Initialize().

◆ m_pDesktop

CComPtr<IShellFolder> CSendToMenu::m_pDesktop
private

Definition at line 65 of file CSendToMenu.h.

Referenced by CSendToMenu(), and GetSpecialFolder().

◆ m_pItems

SENDTO_ITEM* CSendToMenu::m_pItems
private

Definition at line 62 of file CSendToMenu.h.

Referenced by InsertSendToItems(), LoadAllItems(), and UnloadAllItems().

◆ m_pSendTo

CComPtr<IShellFolder> CSendToMenu::m_pSendTo
private

Definition at line 66 of file CSendToMenu.h.

Referenced by CSendToMenu(), DoSendToItem(), and LoadAllItems().


The documentation for this class was generated from the following files: