ReactOS 0.4.15-dev-5666-gc548b97
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 976 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 571 of file CDefaultContextMenu.cpp.

579{
580 MENUITEMINFOW mii;
581 WCHAR wszText[100];
582
583 ZeroMemory(&mii, sizeof(mii));
584 mii.cbSize = sizeof(mii);
585 if (fType == MFT_SEPARATOR)
586 mii.fMask = MIIM_ID | MIIM_TYPE;
587 else if (fType == MFT_STRING)
588 {
590 if ((ULONG_PTR)HIWORD((ULONG_PTR)dwTypeData) == 0)
591 {
592 if (LoadStringW(shell32_hInstance, LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
593 mii.dwTypeData = wszText;
594 else
595 {
596 ERR("failed to load string %p\n", dwTypeData);
597 return;
598 }
599 }
600 else
601 mii.dwTypeData = (LPWSTR)dwTypeData;
602 mii.fState = fState;
603 }
604
605 mii.wID = wID;
606 mii.fType = fType;
607 InsertMenuItemW(hMenu, indexMenu, fByPosition, &mii);
608}
#define shell32_hInstance
#define ERR(fmt,...)
Definition: debug.h:110
#define LOWORD(l)
Definition: pedump.c:82
#define _countof(array)
Definition: sndvol32.h:68
LPWSTR dwTypeData
Definition: winuser.h:3259
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define HIWORD(l)
Definition: typedefs.h:247
#define ZeroMemory
Definition: winbase.h:1670
#define MIIM_ID
Definition: winuser.h:717
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MFT_SEPARATOR
Definition: winuser.h:739
#define MIIM_STATE
Definition: winuser.h:716
#define MFT_STRING
Definition: winuser.h:741
#define MIIM_TYPE
Definition: winuser.h:720
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 1480 of file CDefaultContextMenu.cpp.

1481{
1482 return ShellObjectCreatorInit<CDefaultContextMenu>(pdcm, lpfn, riid, ppv);
1483}
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 1513 of file CDefaultContextMenu.cpp.

1523{
1524 DEFCONTEXTMENU dcm;
1525 dcm.hwnd = hwnd;
1526 dcm.pcmcb = NULL;
1527 dcm.pidlFolder = pidlFolder;
1528 dcm.psf = psf;
1529 dcm.cidl = cidl;
1530 dcm.apidl = apidl;
1532 dcm.cKeys = nKeys;
1533 dcm.aKeys = ahkeyClsKeys;
1534
1537 return hr;
1538
1539 return S_OK;
1540}
static HRESULT CDefaultContextMenu_CreateInstance(const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn, REFIID riid, void **ppv)
#define NULL
Definition: types.h:112
#define S_OK
Definition: intsafe.h:52
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT hr
Definition: shlfolder.c:183
IContextMenuCB * pcmcb
Definition: shlobj.h:2402
IShellFolder * psf
Definition: shlobj.h:2404
IUnknown * punkAssociationInfo
Definition: shlobj.h:2407
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2406
const HKEY * aKeys
Definition: shlobj.h:2409
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2403
_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 282 of file CDefaultContextMenu.cpp.

283{
284 BOOL bRet = FALSE;
285 CComPtr<IDataObject> pDataObj;
286
287 if (SUCCEEDED(OleGetClipboard(&pDataObj)))
288 {
289 FORMATETC formatetc;
290
291 TRACE("pDataObj=%p\n", pDataObj.p);
292
293 /* Set the FORMATETC structure*/
294 InitFormatEtc(formatetc, RegisterClipboardFormatW(CFSTR_SHELLIDLIST), TYMED_HGLOBAL);
295 bRet = SUCCEEDED(pDataObj->QueryGetData(&formatetc));
296 }
297
298 return bRet;
299}
#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:477
#define TRACE(s)
Definition: solgame.cpp:4
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)

Referenced by CDefaultContextMenu::QueryContextMenu().

◆ SHCreateDefaultContextMenu()

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

Definition at line 1492 of file CDefaultContextMenu.cpp.

1493{
1494 HRESULT hr;
1495
1496 if (!ppv)
1497 return E_INVALIDARG;
1498
1501 return hr;
1502
1503 return S_OK;
1504}
#define E_INVALIDARG
Definition: ddrawi.h:101

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

◆ SHGetMenuIdFromMenuMsg()

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

Definition at line 1386 of file CDefaultContextMenu.cpp.

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

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

◆ SHSetMenuIdInMenuMsg()

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

Definition at line 1404 of file CDefaultContextMenu.cpp.

1405{
1406 if (uMsg == WM_DRAWITEM)
1407 {
1408 DRAWITEMSTRUCT* pDrawStruct = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
1409 pDrawStruct->itemID = CmdId;
1410 return S_OK;
1411 }
1412 else if (uMsg == WM_MEASUREITEM)
1413 {
1414 MEASUREITEMSTRUCT* pMeasureStruct = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
1415 pMeasureStruct->itemID = CmdId;
1416 return S_OK;
1417 }
1418
1419 return E_FAIL;
1420}

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_CUT
Definition: shresdef.h:801
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:828
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:802
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:824
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:800
#define FCIDM_SHVIEW_COPYTO
Definition: shresdef.h:806
#define FCIDM_SHVIEW_MOVETO
Definition: shresdef.h:807
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:799
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:821
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:822
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:803

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