ReactOS 0.4.17-dev-683-g0dafdc5
CDefaultContextMenu.cpp File Reference
#include "precomp.h"
#include <compat_undoc.h>
Include dependency graph for CDefaultContextMenu.cpp:

Go to the source code of this file.

Classes

struct  _DynamicShellEntry_
 
struct  _StaticShellEntry_
 
struct  _StaticInvokeCommandMap_
 
class  CDefaultContextMenu
 

Macros

#define MAX_VERB   260
 
#define DCM_FCIDM_SHVIEW_OFFSET   0x7000
 

Typedefs

typedef struct _DynamicShellEntry_ DynamicShellEntry
 
typedef struct _DynamicShellEntry_PDynamicShellEntry
 
typedef struct _StaticShellEntry_ StaticShellEntry
 
typedef struct _StaticShellEntry_PStaticShellEntry
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dmenu)
 
static HRESULT SHELL_GetRegCLSID (HKEY hKey, LPCWSTR SubKey, LPCWSTR Value, CLSID &clsid)
 
static BOOL InsertMenuItemAt (HMENU hMenu, UINT Pos, UINT Flags)
 
static void DCMA_DestroyEntry (DCMENTRY &dcme)
 
void DCMA_Destroy (HDCMA hDCMA)
 
UINT DCMA_InsertMenuItems (_In_ HDCMA hDCMA, _In_ HDCIA hDCIA, _In_opt_ LPCITEMIDLIST pidlFolder, _In_opt_ IDataObject *pDO, _In_opt_ HKEY *pKeys, _In_opt_ UINT nKeys, _In_ QCMINFO *pQCMI, _In_opt_ UINT fCmf, _In_opt_ IUnknown *pUnkSite)
 
HRESULT DCMA_InvokeCommand (HDCMA hDCMA, CMINVOKECOMMANDINFO *pICI)
 
PCSTR MapFcidmCmdToVerb (_In_ UINT_PTR CmdId)
 
UINT MapVerbToDfmCmd (_In_ LPCSTR verba)
 
static HRESULT MapVerbToCmdId (PVOID Verb, BOOL IsUnicode, IContextMenu *pCM, UINT idFirst, UINT idLast)
 
static bool IsVerbListSeparator (WCHAR Ch)
 
static int FindVerbInDefaultVerbList (LPCWSTR List, LPCWSTR Verb)
 
EXTERN_C HRESULT SHELL32_EnumDefaultVerbList (LPCWSTR List, UINT Index, LPWSTR Verb, SIZE_T cchMax)
 
static HRESULT GetFriendlyVerb (_In_ PCWSTR pszVerb, _Out_ PWSTR pszBuf, _In_ SIZE_T cchMax)
 
static BOOL HasClipboardData ()
 
BOOL WINAPI _InsertMenuItemW (HMENU hMenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
 
HRESULT SHGetMenuIdFromMenuMsg (UINT uMsg, LPARAM lParam, UINT *CmdId)
 
static HRESULT CDefaultContextMenu_CreateInstance (const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn, REFIID riid, void **ppv)
 
HRESULT WINAPI SHCreateDefaultContextMenu (const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv)
 
HRESULT WINAPI CDefFolderMenu_Create2 (PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeyClsKeys, IContextMenu **ppcm)
 

Variables

static const struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap []
 

Macro Definition Documentation

◆ DCM_FCIDM_SHVIEW_OFFSET

#define DCM_FCIDM_SHVIEW_OFFSET   0x7000

Definition at line 155 of file CDefaultContextMenu.cpp.

◆ MAX_VERB

#define MAX_VERB   260

Definition at line 15 of file CDefaultContextMenu.cpp.

Typedef Documentation

◆ DynamicShellEntry

◆ PDynamicShellEntry

◆ PStaticShellEntry

◆ StaticShellEntry

Function Documentation

◆ _InsertMenuItemW()

BOOL WINAPI _InsertMenuItemW ( HMENU  hMenu,
UINT  indexMenu,
BOOL  fByPosition,
UINT  wID,
UINT  fType,
LPCWSTR  dwTypeData,
UINT  fState 
)

Definition at line 882 of file CDefaultContextMenu.cpp.

890{
891 MENUITEMINFOW mii;
892 WCHAR wszText[100];
893
894 ZeroMemory(&mii, sizeof(mii));
895 mii.cbSize = sizeof(mii);
896 if (fType == MFT_SEPARATOR)
897 mii.fMask = MIIM_ID | MIIM_TYPE;
898 else if (fType == MFT_STRING)
899 {
901 if (IS_INTRESOURCE(dwTypeData))
902 {
903 if (LoadStringW(shell32_hInstance, LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
904 mii.dwTypeData = wszText;
905 else
906 {
907 ERR("failed to load string %p\n", dwTypeData);
908 return FALSE;
909 }
910 }
911 else
912 mii.dwTypeData = (LPWSTR)dwTypeData;
913 mii.fState = fState;
914 }
915
916 mii.wID = wID;
917 mii.fType = fType;
918 return InsertMenuItemW(hMenu, indexMenu, fByPosition, &mii);
919}
#define shell32_hInstance
#define ERR(fmt,...)
Definition: precomp.h:57
#define FALSE
Definition: types.h:117
#define IS_INTRESOURCE(x)
Definition: loader.c:613
#define ZeroMemory
Definition: minwinbase.h:31
#define LOWORD(l)
Definition: pedump.c:82
short WCHAR
Definition: pedump.c:58
#define LoadStringW
Definition: utils.h:64
#define _countof(array)
Definition: sndvol32.h:70
LPWSTR dwTypeData
Definition: winuser.h:3377
uint16_t * LPWSTR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MIIM_ID
Definition: winuser.h:733
#define MFT_SEPARATOR
Definition: winuser.h:755
#define MIIM_STATE
Definition: winuser.h:732
#define MFT_STRING
Definition: winuser.h:757
#define MIIM_TYPE
Definition: winuser.h:736
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ CDefaultContextMenu_CreateInstance()

static HRESULT CDefaultContextMenu_CreateInstance ( const DEFCONTEXTMENU pdcm,
LPFNDFMCALLBACK  lpfn,
REFIID  riid,
void **  ppv 
)
static

Definition at line 1905 of file CDefaultContextMenu.cpp.

1906{
1907 return ShellObjectCreatorInit<CDefaultContextMenu>(pdcm, lpfn, riid, ppv);
1908}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by CDefFolderMenu_Create2(), and SHCreateDefaultContextMenu().

◆ CDefFolderMenu_Create2()

HRESULT WINAPI CDefFolderMenu_Create2 ( PCIDLIST_ABSOLUTE  pidlFolder,
HWND  hwnd,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
IShellFolder psf,
LPFNDFMCALLBACK  lpfn,
UINT  nKeys,
const HKEY ahkeyClsKeys,
IContextMenu **  ppcm 
)

Definition at line 1938 of file CDefaultContextMenu.cpp.

1948{
1949 DEFCONTEXTMENU dcm;
1950 dcm.hwnd = hwnd;
1951 dcm.pcmcb = NULL;
1952 dcm.pidlFolder = pidlFolder;
1953 dcm.psf = psf;
1954 dcm.cidl = cidl;
1955 dcm.apidl = apidl;
1957 dcm.cKeys = nKeys;
1958 dcm.aKeys = ahkeyClsKeys;
1959
1962 return hr;
1963
1964 return S_OK;
1965}
static HRESULT CDefaultContextMenu_CreateInstance(const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn, REFIID riid, void **ppv)
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
#define S_OK
Definition: intsafe.h:52
IContextMenuCB * pcmcb
Definition: shlobj.h:2568
IShellFolder * psf
Definition: shlobj.h:2570
IUnknown * punkAssociationInfo
Definition: shlobj.h:2573
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2572
const HKEY * aKeys
Definition: shlobj.h:2575
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2569
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define IID_PPV_ARG(Itype, ppType)

Referenced by CDrivesContextMenu_CreateInstance(), CCabFolder::CreateViewObject(), CNetFolder::CreateViewObject(), CRegItemContextMenu_CreateInstance(), CCabFolder::GetUIObjectOf(), CFontExt::GetUIObjectOf(), CZipFolder::GetUIObjectOf(), CNetFolder::GetUIObjectOf(), and CCommonFolder< TSelf, TItemId, TExtractIcon >::GetUIObjectOf().

◆ DCMA_Destroy()

void DCMA_Destroy ( HDCMA  hDCMA)

Definition at line 44 of file CDefaultContextMenu.cpp.

45{
46 UINT i = 0;
47 for (DCMENTRY *p; (p = DCMA_GetEntry(hDCMA, i)) != NULL; ++i)
49 DSA_Destroy(hDCMA);
50}
static void DCMA_DestroyEntry(DCMENTRY &dcme)
#define DCMA_GetEntry(hDCMA, iItem)
Definition: precomp.h:197
BOOL WINAPI DSA_Destroy(HDSA hdsa)
Definition: dsa.c:103
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13

Referenced by CFSDropTarget::_GetEffectFromMenu().

◆ DCMA_DestroyEntry()

static void DCMA_DestroyEntry ( DCMENTRY dcme)
static

Definition at line 35 of file CDefaultContextMenu.cpp.

36{
37 if (!dcme.pCM)
38 return;
40 dcme.pCM->Release();
41 dcme.pCM = NULL;
42}
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: main.c:222
ULONG Release()
IContextMenu * pCM
Definition: precomp.h:191

Referenced by DCMA_Destroy(), and DCMA_InsertMenuItems().

◆ DCMA_InsertMenuItems()

UINT DCMA_InsertMenuItems ( _In_ HDCMA  hDCMA,
_In_ HDCIA  hDCIA,
_In_opt_ LPCITEMIDLIST  pidlFolder,
_In_opt_ IDataObject pDO,
_In_opt_ HKEY pKeys,
_In_opt_ UINT  nKeys,
_In_ QCMINFO pQCMI,
_In_opt_ UINT  fCmf,
_In_opt_ IUnknown pUnkSite 
)

Definition at line 52 of file CDefaultContextMenu.cpp.

62{
63 UINT idCmdBase = pQCMI->idCmdFirst, idCmdFirst = idCmdBase;
64 UINT nOffset = 0;
65
66 // Insert in reverse order
67 for (int iCls = DCIA_GetCount(hDCIA) - 1; iCls >= 0; --iCls)
68 {
69 REFCLSID clsid = *DCIA_GetEntry(hDCIA, iCls);
70 if (fCmf & CMF_DEFAULTONLY)
71 {
72 WCHAR szKey[MAX_PATH];
73 wcscpy(szKey, L"CLSID\\");
74 StringFromGUID2(clsid, szKey + _countof(L"CLSID\\") - 1, CHARS_IN_GUID);
75 wcscpy(szKey + _countof(L"CLSID\\") - 1 + CHARS_IN_GUID - 1, L"\\shellex\\MayChangeDefaultMenu");
77 continue;
78 }
79
80 for (UINT iKey = 0; iKey < nKeys; ++iKey)
81 {
84 if (FAILED(hr))
85 break;
86 if (FAILED(hr = pInit->Initialize(pidlFolder, pDO, pKeys[iKey])))
87 continue;
88
89 IContextMenu *pCM;
90 if (FAILED(hr = pInit->QueryInterface(IID_PPV_ARG(IContextMenu, &pCM))))
91 break;
92 IUnknown_SetSite(pCM, pUnkSite);
93
94 hr = pCM->QueryContextMenu(pQCMI->hmenu, pQCMI->indexMenu + nOffset, idCmdFirst, pQCMI->idCmdLast, fCmf);
95 const UINT nCount = HRESULT_CODE(hr);
96 const UINT idThisFirst = idCmdFirst - idCmdBase;
97 DCMENTRY dcme = { pCM, idThisFirst, idThisFirst + nCount - 1 };
98 if (hr > 0)
99 {
100 idCmdFirst += nCount;
101 if (DSA_AppendItem(hDCMA, &dcme) >= 0)
102 {
103 if (nOffset == 0 && GetMenuDefaultItem(pQCMI->hmenu, TRUE, 0) == 0)
104 nOffset++; // Insert new items below the default
105 break;
106 }
107 }
108 DCMA_DestroyEntry(dcme);
109 }
110 }
111 return idCmdFirst;
112}
#define CHARS_IN_GUID
#define TRUE
Definition: types.h:120
INT WINAPI StringFromGUID2(REFGUID guid, LPOLESTR str, INT cmax)
Definition: combase.c:1525
#define MAX_PATH
Definition: compat.h:34
BOOL RegKeyExists(HKEY hKey, LPCWSTR Path)
Definition: utils.h:49
#define DCIA_GetCount(hDCIA)
Definition: utils.h:126
#define DCIA_GetEntry(hDCIA, iItem)
Definition: utils.h:127
HRESULT WINAPI SHExtCoCreateInstance(_In_opt_ LPCWSTR aclsid, _In_opt_ const CLSID *clsid, _In_opt_ LPUNKNOWN pUnkOuter, _In_ REFIID riid, _Out_ LPVOID *ppv)
Definition: shellole.c:222
#define L(x)
Definition: resources.c:13
PWDFDEVICE_INIT pInit
HRESULT QueryContextMenu([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
#define FAILED(hr)
Definition: intsafe.h:51
const CLSID * clsid
Definition: msctf.cpp:50
#define DSA_AppendItem(hdsa, pitem)
Definition: commctrl.h:4832
#define REFCLSID
Definition: guiddef.h:117
wcscpy
#define HRESULT_CODE(hr)
Definition: winerror.h:188
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)

Referenced by CFSDropTarget::_GetEffectFromMenu().

◆ DCMA_InvokeCommand()

HRESULT DCMA_InvokeCommand ( HDCMA  hDCMA,
CMINVOKECOMMANDINFO *  pICI 
)

Definition at line 114 of file CDefaultContextMenu.cpp.

115{
117 for (UINT i = 0;; ++i)
118 {
119 DCMENTRY *p = DCMA_GetEntry(hDCMA, i);
120 if (!p)
121 return hr;
122
123 UINT id = LOWORD(pICI->lpVerb);
124 if (!IS_INTRESOURCE(pICI->lpVerb))
125 {
126 if (SUCCEEDED(hr = p->pCM->InvokeCommand(pICI)))
127 return hr;
128 }
129 else if (id >= p->idCmdFirst && id <= p->idCmdLast)
130 {
131 CMINVOKECOMMANDINFOEX ici;
132 CopyMemory(&ici, pICI, min(sizeof(ici), pICI->cbSize));
133 ici.cbSize = min(sizeof(ici), pICI->cbSize);
134 ici.lpVerb = MAKEINTRESOURCEA(id - p->idCmdFirst);
135 ici.lpVerbW = (PWSTR)ici.lpVerb;
136 return p->pCM->InvokeCommand((CMINVOKECOMMANDINFO*)&ici);
137 }
138 }
139}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define CopyMemory
Definition: minwinbase.h:29
#define min(a, b)
Definition: monoChain.cc:55
uint16_t * PWSTR
Definition: typedefs.h:56
#define S_FALSE
Definition: winerror.h:3451
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

Referenced by CFSDropTarget::_GetEffectFromMenu().

◆ FindVerbInDefaultVerbList()

static int FindVerbInDefaultVerbList ( LPCWSTR  List,
LPCWSTR  Verb 
)
static

Definition at line 222 of file CDefaultContextMenu.cpp.

223{
224 for (UINT index = 0; *List; ++index)
225 {
226 while (IsVerbListSeparator(*List))
227 List++;
229 while (*List && !IsVerbListSeparator(*List))
230 List++;
231 // "List > Start" to verify that the list item is non-empty to avoid the edge case where Verb is "" and the list contains ",,"
232 if (!_wcsnicmp(Verb, Start, List - Start) && List > Start)
233 return index;
234 }
235 return -1;
236}
static bool IsVerbListSeparator(WCHAR Ch)
static _Out_opt_ PULONGLONG Start
#define index(s, c)
Definition: various.h:29
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:200
GLuint index
Definition: glext.h:6031
const uint16_t * LPCWSTR
Definition: typedefs.h:57
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu().

◆ GetFriendlyVerb()

static HRESULT GetFriendlyVerb ( _In_ PCWSTR  pszVerb,
_Out_ PWSTR  pszBuf,
_In_ SIZE_T  cchMax 
)
static

Definition at line 253 of file CDefaultContextMenu.cpp.

254{
255 static const struct { PCWSTR pszVerb; WORD iResId; } map[] =
256 {
257 // { L"open", IDS_OPEN_VERB }, These two have already been handled
258 // { L"explore", IDS_EXPLORE_VERB },
259 { L"edit", IDS_EDIT_VERB },
260 { L"print", IDS_PRINT_VERB },
261 { L"runas", IDS_RUNAS_VERB },
262 { L"openas", IDS_OPEN_VERB },
263 { L"find", IDS_FIND_VERB },
264 };
265 for (SIZE_T i = 0; i < _countof(map); ++i)
266 {
267 if (!_wcsicmp(pszVerb, map[i].pszVerb) &&
268 LoadStringW(shell32_hInstance, map[i].iResId, pszBuf, cchMax))
269 {
270 return S_OK;
271 }
272 }
273
274 // Try to make a friendly verb based on the verb subkey
275 if (pszVerb[0] < 127 && !StrChrW(pszVerb, '&') && SUCCEEDED(StringCchCopyW(pszBuf + 1, --cchMax, pszVerb)))
276 {
277 *pszBuf = L'&';
278 return S_OK; // This can be changed to S_FALSE if the caller needs to know we faked it
279 }
280 return E_FAIL;
281}
UINT cchMax
Definition: _map.h:48
#define E_FAIL
Definition: ddrawi.h:102
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDS_OPEN_VERB
Definition: shresdef.h:212
#define IDS_FIND_VERB
Definition: shresdef.h:216
#define IDS_PRINT_VERB
Definition: shresdef.h:217
#define IDS_RUNAS_VERB
Definition: shresdef.h:214
#define IDS_EDIT_VERB
Definition: shresdef.h:215
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu().

◆ HasClipboardData()

static BOOL HasClipboardData ( )
static

Definition at line 543 of file CDefaultContextMenu.cpp.

544{
545 BOOL bRet = FALSE;
546 CComPtr<IDataObject> pDataObj;
547
548 if (SUCCEEDED(OleGetClipboard(&pDataObj)))
549 {
550 FORMATETC formatetc;
551
552 TRACE("pDataObj=%p\n", pDataObj.p);
553
554 /* Set the FORMATETC structure*/
555 InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
556 bRet = SUCCEEDED(pDataObj->QueryGetData(&formatetc));
557 }
558
559 return bRet;
560}
HRESULT WINAPI OleGetClipboard(IDataObject **obj)
Definition: clipboard.c:2246
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:560
#define TRACE(s)
Definition: solgame.cpp:4
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)

Referenced by CDefaultContextMenu::QueryContextMenu().

◆ InsertMenuItemAt()

static BOOL InsertMenuItemAt ( HMENU  hMenu,
UINT  Pos,
UINT  Flags 
)
static

Definition at line 26 of file CDefaultContextMenu.cpp.

27{
28 MENUITEMINFOW mii;
29 mii.cbSize = FIELD_OFFSET(MENUITEMINFOW, hbmpItem); // USER32 version agnostic
30 mii.fMask = MIIM_TYPE;
31 mii.fType = Flags;
32 return InsertMenuItemW(hMenu, Pos, TRUE, &mii);
33}
ush Pos
Definition: deflate.h:92
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu().

◆ IsVerbListSeparator()

static bool IsVerbListSeparator ( WCHAR  Ch)
inlinestatic

Definition at line 217 of file CDefaultContextMenu.cpp.

218{
219 return Ch == L' ' || Ch == L','; // learn.microsoft.com/en-us/windows/win32/shell/context-menu-handlers
220}
#define Ch(x, y, z)
Definition: sha2.c:141

Referenced by FindVerbInDefaultVerbList(), and SHELL32_EnumDefaultVerbList().

◆ MapFcidmCmdToVerb()

PCSTR MapFcidmCmdToVerb ( _In_ UINT_PTR  CmdId)

Definition at line 178 of file CDefaultContextMenu.cpp.

179{
180 for (SIZE_T i = 0; i < _countof(g_StaticInvokeCmdMap); ++i)
181 {
182 if (g_StaticInvokeCmdMap[i].IntVerb == CmdId && CmdId)
183 return g_StaticInvokeCmdMap[i].szStringVerb;
184 }
185 return NULL;
186}
static const struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]

Referenced by CDefView::InvokeContextMenuCommand().

◆ MapVerbToCmdId()

static HRESULT MapVerbToCmdId ( PVOID  Verb,
BOOL  IsUnicode,
IContextMenu pCM,
UINT  idFirst,
UINT  idLast 
)
static

Definition at line 199 of file CDefaultContextMenu.cpp.

200{
201 const UINT gcs = IsUnicode ? GCS_VERBW : GCS_VERBA;
202 for (UINT id = idFirst; id <= idLast; ++id)
203 {
205 *buf = UNICODE_NULL;
206 HRESULT hr = pCM->GetCommandString(id, gcs, NULL, (LPSTR)buf, _countof(buf));
207 if (FAILED(hr) || !*buf)
208 continue;
209 else if (IsUnicode && !_wcsicmp((LPWSTR)Verb, buf))
210 return id;
211 else if (!IsUnicode && !lstrcmpiA((LPSTR)Verb, (LPSTR)buf))
212 return id;
213 }
215}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint id
Definition: glext.h:5910
HRESULT GetCommandString([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
#define UNICODE_NULL
char * LPSTR
Definition: typedefs.h:51
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_NOT_FOUND
Definition: winerror.h:1014

◆ MapVerbToDfmCmd()

UINT MapVerbToDfmCmd ( _In_ LPCSTR  verba)

Definition at line 188 of file CDefaultContextMenu.cpp.

189{
190 for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); ++i)
191 {
192 if (!lstrcmpiA(g_StaticInvokeCmdMap[i].szStringVerb, verba))
193 return (int)g_StaticInvokeCmdMap[i].DfmCmd;
194 }
195 return 0;
196}

Referenced by GetDfmCmd().

◆ SHCreateDefaultContextMenu()

HRESULT WINAPI SHCreateDefaultContextMenu ( const DEFCONTEXTMENU pdcm,
REFIID  riid,
void **  ppv 
)

Definition at line 1917 of file CDefaultContextMenu.cpp.

1918{
1919 HRESULT hr;
1920
1921 if (!ppv)
1922 return E_INVALIDARG;
1923
1926 return hr;
1927
1928 return S_OK;
1929}
#define E_INVALIDARG
Definition: ddrawi.h:101

Referenced by CDesktopFolder::CreateViewObject(), CDrivesFolder::CreateViewObject(), CFSFolder::CreateViewObject(), CDesktopFolder::GetUIObjectOf(), CFSFolder::GetUIObjectOf(), and init_function_pointers().

◆ SHELL32_EnumDefaultVerbList()

EXTERN_C HRESULT SHELL32_EnumDefaultVerbList ( LPCWSTR  List,
UINT  Index,
LPWSTR  Verb,
SIZE_T  cchMax 
)

Definition at line 238 of file CDefaultContextMenu.cpp.

239{
240 for (UINT i = 0; *List; ++i)
241 {
242 while (IsVerbListSeparator(*List))
243 List++;
245 while (*List && !IsVerbListSeparator(*List))
246 List++;
247 if (List > Start && i == Index)
249 }
251}
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by HCR_GetDefaultVerbW().

◆ SHELL_GetRegCLSID()

static HRESULT SHELL_GetRegCLSID ( HKEY  hKey,
LPCWSTR  SubKey,
LPCWSTR  Value,
CLSID clsid 
)
static

Definition at line 18 of file CDefaultContextMenu.cpp.

19{
20 WCHAR buf[42];
21 DWORD cb = sizeof(buf);
24}
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
Definition: combase.c:1470
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define err(...)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define RRF_RT_REG_SZ
Definition: winreg.h:58

Referenced by CDefaultContextMenu::InvokeRegVerb().

◆ SHGetMenuIdFromMenuMsg()

HRESULT SHGetMenuIdFromMenuMsg ( UINT  uMsg,
LPARAM  lParam,
UINT CmdId 
)

Definition at line 1833 of file CDefaultContextMenu.cpp.

1834{
1835 if (uMsg == WM_DRAWITEM)
1836 {
1837 DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1838 *CmdId = pDrawStruct->itemID;
1839 return S_OK;
1840 }
1841 else if (uMsg == WM_MEASUREITEM)
1842 {
1843 MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1844 *CmdId = pMeasureStruct->itemID;
1845 return S_OK;
1846 }
1847 return E_FAIL;
1848}
LPARAM lParam
Definition: combotst.c:139
#define WM_DRAWITEM
Definition: winuser.h:1673
#define WM_MEASUREITEM
Definition: winuser.h:1674

Referenced by CDefaultContextMenu::HandleMenuMsg2().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmenu  )

Variable Documentation

◆ g_StaticInvokeCmdMap

const struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
static
Initial value:
=
{
{ "cut", FCIDM_SHVIEW_CUT, },
}
short SHORT
Definition: pedump.c:59
#define DFM_CMD_DELETE
Definition: shlobj.h:2626
#define DFM_CMD_NEWFOLDER
Definition: shlobj.h:2631
#define DFM_CMD_COPY
Definition: shlobj.h:2628
#define DFM_CMD_PASTE
Definition: shlobj.h:2632
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2630
#define DFM_CMD_RENAME
Definition: shlobj.h:2638
#define DFM_CMD_LINK
Definition: shlobj.h:2629
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:871
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:872
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:893
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:870
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:868
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:869
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:867
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:873

Referenced by CDefaultContextMenu::GetCommandString(), MapFcidmCmdToVerb(), CDefaultContextMenu::MapVerbToCmdId(), MapVerbToDfmCmd(), and CDefaultContextMenu::TryPickDefault().