ReactOS 0.4.15-dev-8227-g32d615f
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 RegValueExists (HKEY hKey, LPCWSTR Name)
 
static BOOL InsertMenuItemAt (HMENU hMenu, UINT Pos, UINT Flags)
 
UINT MapVerbToDfmCmd (_In_ LPCSTR verba)
 
static BOOL HasClipboardData ()
 
void WINAPI _InsertMenuItemW (HMENU hMenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
 
HRESULT SHGetMenuIdFromMenuMsg (UINT uMsg, LPARAM lParam, UINT *CmdId)
 
HRESULT SHSetMenuIdInMenuMsg (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 55 of file CDefaultContextMenu.cpp.

◆ MAX_VERB

#define MAX_VERB   260

Definition at line 16 of file CDefaultContextMenu.cpp.

Typedef Documentation

◆ DynamicShellEntry

◆ PDynamicShellEntry

◆ PStaticShellEntry

◆ StaticShellEntry

Function Documentation

◆ _InsertMenuItemW()

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

Definition at line 670 of file CDefaultContextMenu.cpp.

678{
679 MENUITEMINFOW mii;
680 WCHAR wszText[100];
681
682 ZeroMemory(&mii, sizeof(mii));
683 mii.cbSize = sizeof(mii);
684 if (fType == MFT_SEPARATOR)
685 mii.fMask = MIIM_ID | MIIM_TYPE;
686 else if (fType == MFT_STRING)
687 {
689 if (IS_INTRESOURCE(dwTypeData))
690 {
691 if (LoadStringW(shell32_hInstance, LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
692 mii.dwTypeData = wszText;
693 else
694 {
695 ERR("failed to load string %p\n", dwTypeData);
696 return;
697 }
698 }
699 else
700 mii.dwTypeData = (LPWSTR)dwTypeData;
701 mii.fState = fState;
702 }
703
704 mii.wID = wID;
705 mii.fType = fType;
706 InsertMenuItemW(hMenu, indexMenu, fByPosition, &mii);
707}
#define shell32_hInstance
#define ERR(fmt,...)
Definition: debug.h:113
#define LOWORD(l)
Definition: pedump.c:82
#define _countof(array)
Definition: sndvol32.h:70
LPWSTR dwTypeData
Definition: winuser.h:3269
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ZeroMemory
Definition: winbase.h:1712
#define MIIM_ID
Definition: winuser.h:722
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define MFT_SEPARATOR
Definition: winuser.h:744
#define MIIM_STATE
Definition: winuser.h:721
#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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CDefaultContextMenu_CreateInstance()

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

Definition at line 1673 of file CDefaultContextMenu.cpp.

1674{
1675 return ShellObjectCreatorInit<CDefaultContextMenu>(pdcm, lpfn, riid, ppv);
1676}
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 1706 of file CDefaultContextMenu.cpp.

1716{
1717 DEFCONTEXTMENU dcm;
1718 dcm.hwnd = hwnd;
1719 dcm.pcmcb = NULL;
1720 dcm.pidlFolder = pidlFolder;
1721 dcm.psf = psf;
1722 dcm.cidl = cidl;
1723 dcm.apidl = apidl;
1725 dcm.cKeys = nKeys;
1726 dcm.aKeys = ahkeyClsKeys;
1727
1730 return hr;
1731
1732 return S_OK;
1733}
static HRESULT CDefaultContextMenu_CreateInstance(const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn, REFIID riid, void **ppv)
#define NULL
Definition: types.h:112
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183
IContextMenuCB * pcmcb
Definition: shlobj.h:2543
IShellFolder * psf
Definition: shlobj.h:2545
IUnknown * punkAssociationInfo
Definition: shlobj.h:2548
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2547
const HKEY * aKeys
Definition: shlobj.h:2550
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2544
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define IID_PPV_ARG(Itype, ppType)

Referenced by _CFontMenu_CreateInstance(), CDrivesContextMenu_CreateInstance(), CGuidItemContextMenu_CreateInstance(), CZipFolder::GetUIObjectOf(), CNetFolder::GetUIObjectOf(), and CCommonFolder< TSelf, TItemId, TExtractIcon >::GetUIObjectOf().

◆ HasClipboardData()

static BOOL HasClipboardData ( )
static

Definition at line 334 of file CDefaultContextMenu.cpp.

335{
336 BOOL bRet = FALSE;
337 CComPtr<IDataObject> pDataObj;
338
339 if (SUCCEEDED(OleGetClipboard(&pDataObj)))
340 {
341 FORMATETC formatetc;
342
343 TRACE("pDataObj=%p\n", pDataObj.p);
344
345 /* Set the FORMATETC structure*/
346 InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
347 bRet = SUCCEEDED(pDataObj->QueryGetData(&formatetc));
348 }
349
350 return bRet;
351}
#define FALSE
Definition: types.h:117
HRESULT WINAPI OleGetClipboard(IDataObject **obj)
Definition: clipboard.c:2249
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:550
#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 32 of file CDefaultContextMenu.cpp.

33{
34 MENUITEMINFOW mii;
35 mii.cbSize = FIELD_OFFSET(MENUITEMINFOW, hbmpItem); // USER32 version agnostic
36 mii.fMask = MIIM_TYPE;
37 mii.fType = Flags;
38 return InsertMenuItemW(hMenu, Pos, TRUE, &mii);
39}
ush Pos
Definition: deflate.h:92
#define TRUE
Definition: types.h:120
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu().

◆ MapVerbToDfmCmd()

UINT MapVerbToDfmCmd ( _In_ LPCSTR  verba)

Definition at line 83 of file CDefaultContextMenu.cpp.

84{
85 for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); ++i)
86 {
87 if (!lstrcmpiA(g_StaticInvokeCmdMap[i].szStringVerb, verba))
88 return (int)g_StaticInvokeCmdMap[i].DfmCmd;
89 }
90 return 0;
91}
static const struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
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: ndis.h:50

Referenced by GetDfmCmd().

◆ RegValueExists()

static bool RegValueExists ( HKEY  hKey,
LPCWSTR  Name 
)
inlinestatic

Definition at line 27 of file CDefaultContextMenu.cpp.

28{
30}
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey

Referenced by CDefaultContextMenu::AddStaticContextMenusToMenu().

◆ SHCreateDefaultContextMenu()

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

Definition at line 1685 of file CDefaultContextMenu.cpp.

1686{
1687 HRESULT hr;
1688
1689 if (!ppv)
1690 return E_INVALIDARG;
1691
1694 return hr;
1695
1696 return S_OK;
1697}
#define E_INVALIDARG
Definition: ddrawi.h:101

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

◆ SHELL_GetRegCLSID()

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

Definition at line 19 of file CDefaultContextMenu.cpp.

20{
21 WCHAR buf[42];
22 DWORD cb = sizeof(buf);
25}
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 idstr, LPCLSID id)
Definition: compobj.c:2338
#define RRF_RT_REG_SZ
Definition: driver.c:575
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
REFCLSID clsid
Definition: msctf.c:82
#define err(...)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by CDefaultContextMenu::InvokeRegVerb().

◆ SHGetMenuIdFromMenuMsg()

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

Definition at line 1579 of file CDefaultContextMenu.cpp.

1580{
1581 if (uMsg == WM_DRAWITEM)
1582 {
1583 DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1584 *CmdId = pDrawStruct->itemID;
1585 return S_OK;
1586 }
1587 else if (uMsg == WM_MEASUREITEM)
1588 {
1589 MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1590 *CmdId = pMeasureStruct->itemID;
1591 return S_OK;
1592 }
1593
1594 return E_FAIL;
1595}
LPARAM lParam
Definition: combotst.c:139
#define E_FAIL
Definition: ddrawi.h:102
#define WM_DRAWITEM
Definition: winuser.h:1645
#define WM_MEASUREITEM
Definition: winuser.h:1646

Referenced by CDefaultContextMenu::HandleMenuMsg2(), and CDefView::OnCustomItem().

◆ SHSetMenuIdInMenuMsg()

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

Definition at line 1597 of file CDefaultContextMenu.cpp.

1598{
1599 if (uMsg == WM_DRAWITEM)
1600 {
1601 DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1602 pDrawStruct->itemID = CmdId;
1603 return S_OK;
1604 }
1605 else if (uMsg == WM_MEASUREITEM)
1606 {
1607 MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1608 pMeasureStruct->itemID = CmdId;
1609 return S_OK;
1610 }
1611
1612 return E_FAIL;
1613}

Referenced by CDefaultContextMenu::HandleMenuMsg2(), and CDefView::OnCustomItem().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmenu  )

Variable Documentation

◆ g_StaticInvokeCmdMap

const struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
static
Initial value:
=
{
{ "RunAs", 0 },
{ "Print", 0 },
{ "Preview", 0 },
{ "Open", FCIDM_SHVIEW_OPEN },
{ "cut", FCIDM_SHVIEW_CUT, },
{ "copyto", FCIDM_SHVIEW_COPYTO },
{ "moveto", FCIDM_SHVIEW_MOVETO },
}
short SHORT
Definition: pedump.c:59
#define DFM_CMD_DELETE
Definition: shlobj.h:2601
#define DFM_CMD_NEWFOLDER
Definition: shlobj.h:2606
#define DFM_CMD_COPY
Definition: shlobj.h:2603
#define DFM_CMD_PASTE
Definition: shlobj.h:2607
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2605
#define DFM_CMD_RENAME
Definition: shlobj.h:2613
#define DFM_CMD_LINK
Definition: shlobj.h:2604
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:831
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:858
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:832
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:854
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:830
#define FCIDM_SHVIEW_COPYTO
Definition: shresdef.h:836
#define FCIDM_SHVIEW_MOVETO
Definition: shresdef.h:837
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:829
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:851
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:852
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:833

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