ReactOS  0.4.15-dev-1200-gc3b3fcd
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

 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 1019 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 626 of file CDefaultContextMenu.cpp.

634 {
635  MENUITEMINFOW mii;
636  WCHAR wszText[100];
637 
638  ZeroMemory(&mii, sizeof(mii));
639  mii.cbSize = sizeof(mii);
640  if (fType == MFT_SEPARATOR)
641  mii.fMask = MIIM_ID | MIIM_TYPE;
642  else if (fType == MFT_STRING)
643  {
644  mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
645  if ((ULONG_PTR)HIWORD((ULONG_PTR)dwTypeData) == 0)
646  {
647  if (LoadStringW(shell32_hInstance, LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
648  mii.dwTypeData = wszText;
649  else
650  {
651  ERR("failed to load string %p\n", dwTypeData);
652  return;
653  }
654  }
655  else
656  mii.dwTypeData = (LPWSTR)dwTypeData;
657  mii.fState = fState;
658  }
659 
660  mii.wID = wID;
661  mii.fType = fType;
662  InsertMenuItemW(hMenu, indexMenu, fByPosition, &mii);
663 }
#define MFT_STRING
Definition: winuser.h:741
#define ZeroMemory
Definition: winbase.h:1648
LPWSTR dwTypeData
Definition: winuser.h:3244
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:65
#define MIIM_STATE
Definition: winuser.h:716
#define MIIM_ID
Definition: winuser.h:717
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MIIM_TYPE
Definition: winuser.h:720
#define ERR(fmt,...)
Definition: debug.h:110
#define shell32_hInstance
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define HIWORD(l)
Definition: typedefs.h:247
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 1515 of file CDefaultContextMenu.cpp.

1516 {
1517  return ShellObjectCreatorInit<CDefaultContextMenu>(pdcm, lpfn, riid, ppv);
1518 }
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 1548 of file CDefaultContextMenu.cpp.

1558 {
1559  DEFCONTEXTMENU dcm;
1560  dcm.hwnd = hwnd;
1561  dcm.pcmcb = NULL;
1562  dcm.pidlFolder = pidlFolder;
1563  dcm.psf = psf;
1564  dcm.cidl = cidl;
1565  dcm.apidl = apidl;
1566  dcm.punkAssociationInfo = NULL;
1567  dcm.cKeys = nKeys;
1568  dcm.aKeys = ahkeyClsKeys;
1569 
1571  if (FAILED_UNEXPECTEDLY(hr))
1572  return hr;
1573 
1574  return S_OK;
1575 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
const HKEY * aKeys
Definition: shlobj.h:2374
IContextMenuCB * pcmcb
Definition: shlobj.h:2367
#define IID_PPV_ARG(Itype, ppType)
IShellFolder * psf
Definition: shlobj.h:2369
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:79
#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:51
IUnknown * punkAssociationInfo
Definition: shlobj.h:2372
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2371
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2368

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

◆ HasClipboardData()

static BOOL HasClipboardData ( )
static

Definition at line 316 of file CDefaultContextMenu.cpp.

317 {
318  BOOL bRet = FALSE;
319  CComPtr<IDataObject> pDataObj;
320 
321  if (SUCCEEDED(OleGetClipboard(&pDataObj)))
322  {
323  FORMATETC formatetc;
324 
325  TRACE("pDataObj=%p\n", pDataObj.p);
326 
327  /* Set the FORMATETC structure*/
328  InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
329  bRet = SUCCEEDED(pDataObj->QueryGetData(&formatetc));
330  }
331 
332  return bRet;
333 }
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:477
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define FALSE
Definition: types.h:117
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:49

Referenced by CDefaultContextMenu::QueryContextMenu().

◆ SHCreateDefaultContextMenu()

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

Definition at line 1527 of file CDefaultContextMenu.cpp.

1528 {
1529  HRESULT hr;
1530 
1531  if (!ppv)
1532  return E_INVALIDARG;
1533 
1535  if (FAILED_UNEXPECTEDLY(hr))
1536  return hr;
1537 
1538  return S_OK;
1539 }
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:79
#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:51

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

◆ SHGetMenuIdFromMenuMsg()

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

Definition at line 1421 of file CDefaultContextMenu.cpp.

1422 {
1423  if (uMsg == WM_DRAWITEM)
1424  {
1425  DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1426  *CmdId = pDrawStruct->itemID;
1427  return S_OK;
1428  }
1429  else if (uMsg == WM_MEASUREITEM)
1430  {
1431  MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1432  *CmdId = pMeasureStruct->itemID;
1433  return S_OK;
1434  }
1435 
1436  return E_FAIL;
1437 }
#define E_FAIL
Definition: ddrawi.h:102
#define WM_MEASUREITEM
Definition: winuser.h:1628
#define S_OK
Definition: intsafe.h:51
#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 1439 of file CDefaultContextMenu.cpp.

1440 {
1441  if (uMsg == WM_DRAWITEM)
1442  {
1443  DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1444  pDrawStruct->itemID = CmdId;
1445  return S_OK;
1446  }
1447  else if (uMsg == WM_MEASUREITEM)
1448  {
1449  MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1450  pMeasureStruct->itemID = CmdId;
1451  return S_OK;
1452  }
1453 
1454  return E_FAIL;
1455 }
#define E_FAIL
Definition: ddrawi.h:102
#define WM_MEASUREITEM
Definition: winuser.h:1628
#define S_OK
Definition: intsafe.h:51
#define WM_DRAWITEM
Definition: winuser.h:1627
LPARAM lParam
Definition: combotst.c:139

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

◆ 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},
{ "copyto", FCIDM_SHVIEW_COPYTO },
{ "moveto", FCIDM_SHVIEW_MOVETO },
}
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:794
#define FCIDM_SHVIEW_COPYTO
Definition: shresdef.h:772
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:766
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:769
#define FCIDM_SHVIEW_MOVETO
Definition: shresdef.h:773
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:790
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:768
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:765
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:788
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:787
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:767

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