ReactOS  0.4.14-dev-41-g31d7680
CDefaultContextMenu.cpp File Reference
#include "precomp.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
 

Typedefs

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

Functions

DWORD WINAPI SHAnsiToUnicode (LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
 
INT WINAPI SHUnicodeToAnsi (LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
 
 WINE_DEFAULT_DEBUG_CHANNEL (dmenu)
 
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

struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap []
 

Macro Definition Documentation

◆ MAX_VERB

#define MAX_VERB   260

Definition at line 974 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 623 of file CDefaultContextMenu.cpp.

631 {
632  MENUITEMINFOW mii;
633  WCHAR wszText[100];
634 
635  ZeroMemory(&mii, sizeof(mii));
636  mii.cbSize = sizeof(mii);
637  if (fType == MFT_SEPARATOR)
638  mii.fMask = MIIM_ID | MIIM_TYPE;
639  else if (fType == MFT_STRING)
640  {
641  mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
642  if ((ULONG_PTR)HIWORD((ULONG_PTR)dwTypeData) == 0)
643  {
644  if (LoadStringW(shell32_hInstance, LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
645  mii.dwTypeData = wszText;
646  else
647  {
648  ERR("failed to load string %p\n", dwTypeData);
649  return;
650  }
651  }
652  else
653  mii.dwTypeData = (LPWSTR)dwTypeData;
654  mii.fState = fState;
655  }
656 
657  mii.wID = wID;
658  mii.fType = fType;
659  InsertMenuItemW(hMenu, indexMenu, fByPosition, &mii);
660 }
#define MFT_STRING
Definition: winuser.h:741
#define _countof(array)
Definition: fontsub.cpp:30
#define ZeroMemory
Definition: winbase.h:1635
LPWSTR dwTypeData
Definition: winuser.h:3243
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
uint32_t ULONG_PTR
Definition: typedefs.h:63
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define MIIM_STATE
Definition: winuser.h:716
#define MIIM_ID
Definition: winuser.h:717
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MIIM_TYPE
Definition: winuser.h:720
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define HIWORD(l)
Definition: typedefs.h:246
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define LOWORD(l)
Definition: pedump.c:82

◆ CDefaultContextMenu_CreateInstance()

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

Definition at line 1461 of file CDefaultContextMenu.cpp.

1462 {
1463  return ShellObjectCreatorInit<CDefaultContextMenu>(pdcm, lpfn, riid, ppv);
1464 }
REFIID riid
Definition: precomp.h:44
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 1494 of file CDefaultContextMenu.cpp.

1504 {
1505  DEFCONTEXTMENU dcm;
1506  dcm.hwnd = hwnd;
1507  dcm.pcmcb = NULL;
1508  dcm.pidlFolder = pidlFolder;
1509  dcm.psf = psf;
1510  dcm.cidl = cidl;
1511  dcm.apidl = apidl;
1512  dcm.punkAssociationInfo = NULL;
1513  dcm.cKeys = nKeys;
1514  dcm.aKeys = ahkeyClsKeys;
1515 
1517  if (FAILED_UNEXPECTEDLY(hr))
1518  return hr;
1519 
1520  return S_OK;
1521 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
const HKEY * aKeys
Definition: shlobj.h:2348
IContextMenuCB * pcmcb
Definition: shlobj.h:2341
#define IID_PPV_ARG(Itype, ppType)
IShellFolder * psf
Definition: shlobj.h:2343
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
static HRESULT CDefaultContextMenu_CreateInstance(const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn, REFIID riid, void **ppv)
#define S_OK
Definition: intsafe.h:59
IUnknown * punkAssociationInfo
Definition: shlobj.h:2346
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2345
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2342

Referenced by CDrivesContextMenu_CreateInstance(), CGuidItemContextMenu_CreateInstance(), CNetFolder::GetUIObjectOf(), CZipFolder::GetUIObjectOf(), and CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::GetUIObjectOf().

◆ HasClipboardData()

static BOOL HasClipboardData ( )
static

Definition at line 321 of file CDefaultContextMenu.cpp.

322 {
323  BOOL bRet = FALSE;
324  CComPtr<IDataObject> pDataObj;
325 
326  if (SUCCEEDED(OleGetClipboard(&pDataObj)))
327  {
328  STGMEDIUM medium;
329  FORMATETC formatetc;
330 
331  TRACE("pDataObj=%p\n", pDataObj.p);
332 
333  /* Set the FORMATETC structure*/
334  InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
335  if (SUCCEEDED(pDataObj->GetData(&formatetc, &medium)))
336  {
337  bRet = TRUE;
338  ReleaseStgMedium(&medium);
339  }
340  }
341 
342  return bRet;
343 }
#define TRUE
Definition: types.h:120
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:469
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:33
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2036
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT WINAPI OleGetClipboard(IDataObject **obj)
Definition: clipboard.c:2249
#define TRACE(s)
Definition: solgame.cpp:4
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CDefaultContextMenu::QueryContextMenu().

◆ SHAnsiToUnicode()

DWORD WINAPI SHAnsiToUnicode ( LPCSTR  lpSrcStr,
LPWSTR  lpDstStr,
int  iLen 
)

Definition at line 2625 of file string.c.

2626 {
2627  return SHAnsiToUnicodeCP(CP_ACP, lpSrcStr, lpDstStr, iLen);
2628 }
#define CP_ACP
Definition: compat.h:99
DWORD WINAPI SHAnsiToUnicodeCP(DWORD dwCp, LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2600

Referenced by DoesStringRoundTripW(), CDefaultContextMenu::GetCommandString(), and CDefaultContextMenu::MapVerbToCmdId().

◆ SHCreateDefaultContextMenu()

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

Definition at line 1473 of file CDefaultContextMenu.cpp.

1474 {
1475  HRESULT hr;
1476 
1477  if (!ppv)
1478  return E_INVALIDARG;
1479 
1481  if (FAILED_UNEXPECTEDLY(hr))
1482  return hr;
1483 
1484  return S_OK;
1485 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
static HRESULT CDefaultContextMenu_CreateInstance(const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn, REFIID riid, void **ppv)
#define S_OK
Definition: intsafe.h:59

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

◆ SHGetMenuIdFromMenuMsg()

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

Definition at line 1367 of file CDefaultContextMenu.cpp.

1368 {
1369  if (uMsg == WM_DRAWITEM)
1370  {
1371  DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1372  *CmdId = pDrawStruct->itemID;
1373  return S_OK;
1374  }
1375  else if (uMsg == WM_MEASUREITEM)
1376  {
1377  MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1378  *CmdId = pMeasureStruct->itemID;
1379  return S_OK;
1380  }
1381 
1382  return E_FAIL;
1383 }
#define E_FAIL
Definition: ddrawi.h:102
#define WM_MEASUREITEM
Definition: winuser.h:1628
#define S_OK
Definition: intsafe.h:59
#define WM_DRAWITEM
Definition: winuser.h:1627
LPARAM lParam
Definition: combotst.c:139

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

◆ SHSetMenuIdInMenuMsg()

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

Definition at line 1385 of file CDefaultContextMenu.cpp.

1386 {
1387  if (uMsg == WM_DRAWITEM)
1388  {
1389  DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1390  pDrawStruct->itemID = CmdId;
1391  return S_OK;
1392  }
1393  else if (uMsg == WM_MEASUREITEM)
1394  {
1395  MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1396  pMeasureStruct->itemID = CmdId;
1397  return S_OK;
1398  }
1399 
1400  return E_FAIL;
1401 }
#define E_FAIL
Definition: ddrawi.h:102
#define WM_MEASUREITEM
Definition: winuser.h:1628
#define S_OK
Definition: intsafe.h:59
#define WM_DRAWITEM
Definition: winuser.h:1627
LPARAM lParam
Definition: combotst.c:139

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

◆ SHUnicodeToAnsi()

INT WINAPI SHUnicodeToAnsi ( LPCWSTR  lpSrcStr,
LPSTR  lpDstStr,
INT  iLen 
)

Definition at line 2749 of file string.c.

2750 {
2751  return SHUnicodeToAnsiCP(CP_ACP, lpSrcStr, lpDstStr, iLen);
2752 }
#define CP_ACP
Definition: compat.h:99
DWORD WINAPI SHUnicodeToAnsiCP(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr, int dstlen)
Definition: string.c:2650

Referenced by DoesStringRoundTripW(), and CDefaultContextMenu::GetCommandString().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmenu  )

Variable Documentation

◆ g_StaticInvokeCmdMap

struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
Initial value:
=
{
{ "RunAs", 0 },
{ "Print", 0 },
{ "Preview", 0 },
{ "Open", FCIDM_SHVIEW_OPEN },
{ CMDSTR_NEWFOLDERA, FCIDM_SHVIEW_NEWFOLDER },
{ "cut", FCIDM_SHVIEW_CUT},
{ "copy", FCIDM_SHVIEW_COPY},
{ "paste", FCIDM_SHVIEW_INSERT},
{ "delete", FCIDM_SHVIEW_DELETE},
{ "properties", FCIDM_SHVIEW_PROPERTIES},
{ "rename", FCIDM_SHVIEW_RENAME},
}
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:761
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:734
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:737
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:757
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:736
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:733
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:755
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:754
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:735

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