ReactOS  0.4.14-dev-358-gbef841c
COpenWithMenu Class Reference

#include <COpenWithMenu.h>

Inheritance diagram for COpenWithMenu:
Collaboration diagram for COpenWithMenu:

Public Member Functions

 COpenWithMenu ()
 
 ~COpenWithMenu ()
 
virtual HRESULT WINAPI QueryContextMenu (HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
virtual HRESULT WINAPI InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
 
virtual HRESULT WINAPI GetCommandString (UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen)
 
virtual HRESULT WINAPI HandleMenuMsg (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual HRESULT STDMETHODCALLTYPE Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Member Functions

HBITMAP IconToBitmap (HICON hIcon)
 
VOID AddChooseProgramItem ()
 
VOID AddApp (PVOID pApp)
 

Private Attributes

UINT m_idCmdFirst
 
UINT m_idCmdLast
 
WCHAR m_wszPath [MAX_PATH]
 
HMENU m_hSubMenu
 
COpenWithListm_pAppList
 

Additional Inherited Members

- Public Types inherited from IContextMenu2
typedef IContextMenu2LPCONTEXTMENU2
 
- Public Types inherited from IContextMenu
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IShellExtInit
typedef IShellExtInitLPSHELLEXTINIT
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 28 of file COpenWithMenu.h.

Constructor & Destructor Documentation

◆ COpenWithMenu()

COpenWithMenu::COpenWithMenu ( )

Definition at line 1076 of file COpenWithMenu.cpp.

1077 {
1078  m_idCmdFirst = 0;
1079  m_idCmdLast = 0;
1080  m_pAppList = new COpenWithList;
1081 }
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38

◆ ~COpenWithMenu()

COpenWithMenu::~COpenWithMenu ( )

Definition at line 1083 of file COpenWithMenu.cpp.

1084 {
1085  TRACE("Destroying COpenWithMenu(%p)\n", this);
1086 
1087  if (m_hSubMenu)
1088  {
1089  INT Count, Index;
1090  MENUITEMINFOW mii;
1091 
1092  /* get item count */
1094  if (Count == -1)
1095  return;
1096 
1097  /* setup menuitem info */
1098  ZeroMemory(&mii, sizeof(mii));
1099  mii.cbSize = sizeof(mii);
1101 
1102  for(Index = 0; Index < Count; Index++)
1103  {
1104  if (GetMenuItemInfoW(m_hSubMenu, Index, TRUE, &mii))
1105  {
1106  if (mii.hbmpChecked)
1108  }
1109  }
1110  }
1111 
1112  if (m_pAppList)
1113  delete m_pAppList;
1114 }
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
HBITMAP hbmpChecked
Definition: winuser.h:3240
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define ZeroMemory
Definition: winbase.h:1642
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int32_t INT
Definition: typedefs.h:56
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define TRACE(s)
Definition: solgame.cpp:4
static const UCHAR Index[8]
Definition: usbohci.c:18
#define MIIM_CHECKMARKS
Definition: winuser.h:719
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38
#define MIIM_DATA
Definition: winuser.h:721

Member Function Documentation

◆ AddApp()

VOID COpenWithMenu::AddApp ( PVOID  pApp)
private

Definition at line 1167 of file COpenWithMenu.cpp.

1168 {
1169  MENUITEMINFOW mii;
1170  LPCWSTR pwszName = m_pAppList->GetName((COpenWithList::SApp*)pApp);
1171 
1172  ZeroMemory(&mii, sizeof(mii));
1173  mii.cbSize = sizeof(mii);
1175  mii.fType = MFT_STRING;
1176  mii.fState = MFS_ENABLED;
1177  mii.wID = m_idCmdLast;
1178  mii.dwTypeData = (LPWSTR)pwszName;
1179  mii.cch = wcslen(mii.dwTypeData);
1180  mii.dwItemData = (ULONG_PTR)pApp;
1181 
1183  if (hIcon)
1184  {
1185  mii.fMask |= MIIM_CHECKMARKS;
1187  }
1188 
1189  if (InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii))
1190  m_idCmdLast++;
1191 }
static HICON
Definition: imagelist.c:84
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
HBITMAP hbmpChecked
Definition: winuser.h:3240
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HBITMAP IconToBitmap(HICON hIcon)
#define ZeroMemory
Definition: winbase.h:1642
LPWSTR dwTypeData
Definition: winuser.h:3243
static HICON GetIcon(SApp *pApp)
#define MFS_ENABLED
Definition: winuser.h:745
#define MIIM_STATE
Definition: winuser.h:716
static LPCWSTR GetName(SApp *pApp)
#define MIIM_ID
Definition: winuser.h:717
#define MIIM_TYPE
Definition: winuser.h:720
#define MIIM_CHECKMARKS
Definition: winuser.h:719
HICON hIcon
Definition: msconfig.c:44
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38
#define ULONG_PTR
Definition: config.h:101
HBITMAP hbmpUnchecked
Definition: winuser.h:3241
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
ULONG_PTR dwItemData
Definition: winuser.h:3242
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by QueryContextMenu().

◆ AddChooseProgramItem()

VOID COpenWithMenu::AddChooseProgramItem ( )
private

Definition at line 1139 of file COpenWithMenu.cpp.

1140 {
1141  MENUITEMINFOW mii;
1142  WCHAR wszBuf[128];
1143 
1144  ZeroMemory(&mii, sizeof(mii));
1145  mii.cbSize = sizeof(mii);
1146  mii.fMask = MIIM_TYPE | MIIM_ID;
1147  mii.fType = MFT_SEPARATOR;
1148  mii.wID = -1;
1149  InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii);
1150 
1152  {
1153  ERR("Failed to load string\n");
1154  return;
1155  }
1156 
1157  mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
1158  mii.fType = MFT_STRING;
1159  mii.fState = MFS_ENABLED;
1160  mii.wID = m_idCmdLast;
1161  mii.dwTypeData = (LPWSTR)wszBuf;
1162  mii.cch = wcslen(wszBuf);
1163 
1164  InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii);
1165 }
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
#define _countof(array)
Definition: fontsub.cpp:30
#define ZeroMemory
Definition: winbase.h:1642
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)
#define MFS_ENABLED
Definition: winuser.h:745
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define IDS_OPEN_WITH_CHOOSE
Definition: shresdef.h:127
#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)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by QueryContextMenu().

◆ GetCommandString()

HRESULT WINAPI COpenWithMenu::GetCommandString ( UINT_PTR  idCommand,
UINT  uFlags,
UINT lpReserved,
LPSTR  lpszName,
UINT  uMaxNameLen 
)
virtual

Implements IContextMenu.

Definition at line 1310 of file COpenWithMenu.cpp.

1312 {
1313  FIXME("%p %lu %u %p %p %u\n", this,
1314  idCmd, uType, pwReserved, pszName, cchMax );
1315 
1316  return E_NOTIMPL;
1317 }
#define FIXME(fmt,...)
Definition: debug.h:110
UINT cchMax
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ HandleMenuMsg()

HRESULT WINAPI COpenWithMenu::HandleMenuMsg ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

Implements IContextMenu2.

Definition at line 1319 of file COpenWithMenu.cpp.

1323 {
1324  TRACE("This %p uMsg %x\n", this, uMsg);
1325 
1326  return E_NOTIMPL;
1327 }
UINT uMsg
Definition: menu.cpp:213
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IconToBitmap()

HBITMAP COpenWithMenu::IconToBitmap ( HICON  hIcon)
private

Definition at line 1116 of file COpenWithMenu.cpp.

1117 {
1118  HDC hdc, hdcScr;
1119  HBITMAP hbm, hbmOld;
1120  RECT rc;
1121 
1122  hdcScr = GetDC(NULL);
1123  hdc = CreateCompatibleDC(hdcScr);
1125  hbm = CreateCompatibleBitmap(hdcScr, rc.right, rc.bottom);
1126  ReleaseDC(NULL, hdcScr);
1127 
1128  hbmOld = (HBITMAP)SelectObject(hdc, hbm);
1129  FillRect(hdc, &rc, (HBRUSH)(COLOR_MENU + 1));
1130  if (!DrawIconEx(hdc, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
1131  ERR("DrawIcon failed: %x\n", GetLastError());
1132  SelectObject(hdc, hbmOld);
1133 
1134  DeleteDC(hdc);
1135 
1136  return hbm;
1137 }
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
#define SM_CXMENUCHECK
Definition: winuser.h:1021
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
LONG right
Definition: windef.h:293
#define SM_CYMENUCHECK
Definition: winuser.h:1022
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define COLOR_MENU
Definition: winuser.h:907
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
int WINAPI GetSystemMetrics(_In_ int)
HDC hdc
Definition: main.c:9
#define DI_NORMAL
Definition: wingdi.h:72
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
HICON hIcon
Definition: msconfig.c:44
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
LONG bottom
Definition: windef.h:294
static HBITMAP
Definition: button.c:44
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

Referenced by AddApp().

◆ Initialize()

HRESULT WINAPI COpenWithMenu::Initialize ( PCIDLIST_ABSOLUTE  pidlFolder,
IDataObject pdtobj,
HKEY  hkeyProgID 
)
virtual

Implements IShellExtInit.

Definition at line 1330 of file COpenWithMenu.cpp.

1333 {
1334  STGMEDIUM medium;
1335  FORMATETC fmt;
1336  HRESULT hr;
1337  LPIDA pida;
1338  LPCITEMIDLIST pidlFolder2;
1339  LPCITEMIDLIST pidlChild;
1340  LPCITEMIDLIST pidl;
1341  LPCWSTR pwszExt;
1342 
1343  TRACE("This %p\n", this);
1344 
1345  if (pdtobj == NULL)
1346  return E_INVALIDARG;
1347 
1349  fmt.ptd = NULL;
1350  fmt.dwAspect = DVASPECT_CONTENT;
1351  fmt.lindex = -1;
1352  fmt.tymed = TYMED_HGLOBAL;
1353 
1354  hr = pdtobj->GetData(&fmt, &medium);
1355 
1356  if (FAILED(hr))
1357  {
1358  ERR("pdtobj->GetData failed with 0x%x\n", hr);
1359  return hr;
1360  }
1361 
1362  pida = (LPIDA)GlobalLock(medium.hGlobal);
1363  ASSERT(pida->cidl >= 1);
1364 
1365  pidlFolder2 = (LPCITEMIDLIST) ((LPBYTE)pida + pida->aoffset[0]);
1366  pidlChild = (LPCITEMIDLIST) ((LPBYTE)pida + pida->aoffset[1]);
1367 
1368  if (!_ILIsValue(pidlChild))
1369  {
1370  TRACE("pidl is not a file\n");
1371  GlobalUnlock(medium.hGlobal);
1372  ReleaseStgMedium(&medium);
1373  return E_FAIL;
1374  }
1375 
1376  pidl = ILCombine(pidlFolder2, pidlChild);
1377 
1378  GlobalUnlock(medium.hGlobal);
1379  ReleaseStgMedium(&medium);
1380 
1381  if (!pidl)
1382  {
1383  ERR("no mem\n");
1384  return E_OUTOFMEMORY;
1385  }
1386 
1387  if (!SHGetPathFromIDListW(pidl, m_wszPath))
1388  {
1389  SHFree((void*)pidl);
1390  ERR("SHGetPathFromIDListW failed\n");
1391  return E_FAIL;
1392  }
1393 
1394  SHFree((void*)pidl);
1395  TRACE("szPath %s\n", debugstr_w(m_wszPath));
1396 
1397  pwszExt = PathFindExtensionW(m_wszPath);
1398  if (PathIsExeW(pwszExt) || !_wcsicmp(pwszExt, L".lnk"))
1399  {
1400  TRACE("file is a executable or shortcut\n");
1401  return E_FAIL;
1402  }
1403 
1404  return S_OK;
1405 }
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:469
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
const char * fmt
Definition: wsprintf.c:30
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define E_FAIL
Definition: ddrawi.h:102
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
struct CIDA * LPIDA
EXTERN_C BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:196
UINT cidl
Definition: shlobj.h:491
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:1960
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
UINT aoffset[1]
Definition: shlobj.h:492
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
Definition: dsound.c:943
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: shlobj.h:490

◆ InvokeCommand()

HRESULT WINAPI COpenWithMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
virtual

Implements IContextMenu.

Definition at line 1268 of file COpenWithMenu.cpp.

1269 {
1270  HRESULT hr = E_FAIL;
1271 
1272  TRACE("This %p idFirst %u idLast %u idCmd %u\n", this, m_idCmdFirst, m_idCmdLast, m_idCmdFirst + LOWORD(lpici->lpVerb));
1273 
1274  if (HIWORD(lpici->lpVerb) == 0 && m_idCmdFirst + LOWORD(lpici->lpVerb) <= m_idCmdLast)
1275  {
1276  if (m_idCmdFirst + LOWORD(lpici->lpVerb) == m_idCmdLast)
1277  {
1278  OPENASINFO info;
1280 
1281  info.pcszFile = m_wszPath;
1282  info.oaifInFlags = OAIF_EXEC;
1283  if (pwszExt[0])
1285  info.pcszClass = NULL;
1286  hr = SHOpenWithDialog(lpici->hwnd, &info);
1287  }
1288  else
1289  {
1290  /* retrieve menu item info */
1291  MENUITEMINFOW mii;
1292  ZeroMemory(&mii, sizeof(mii));
1293  mii.cbSize = sizeof(mii);
1294  mii.fMask = MIIM_DATA | MIIM_FTYPE;
1295 
1296  if (GetMenuItemInfoW(m_hSubMenu, LOWORD(lpici->lpVerb), TRUE, &mii) && mii.dwItemData)
1297  {
1298  /* launch item with specified app */
1301  hr = S_OK;
1302  }
1303  }
1304  }
1305 
1306  return hr;
1307 }
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
#define MIIM_FTYPE
Definition: winuser.h:724
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ZeroMemory
Definition: winbase.h:1642
#define E_FAIL
Definition: ddrawi.h:102
struct _test_info info[]
Definition: SetCursorPos.c:19
smooth NULL
Definition: ftsmooth.c:416
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define HIWORD(l)
Definition: typedefs.h:246
#define MIIM_DATA
Definition: winuser.h:721
ULONG_PTR dwItemData
Definition: winuser.h:3242
#define LOWORD(l)
Definition: pedump.c:82
static BOOL Execute(SApp *pApp, LPCWSTR pwszFilePath)

◆ QueryContextMenu()

HRESULT WINAPI COpenWithMenu::QueryContextMenu ( HMENU  hMenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
virtual

Implements IContextMenu.

Definition at line 1193 of file COpenWithMenu.cpp.

1199 {
1200  TRACE("hMenu %p indexMenu %u idFirst %u idLast %u uFlags %u\n", hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
1201 
1202  INT DefaultPos = GetMenuDefaultItem(hMenu, TRUE, 0);
1203 
1204  WCHAR wszName[100];
1205  UINT NameId = (DefaultPos == -1 ? IDS_OPEN : IDS_OPEN_WITH);
1206  if (!LoadStringW(shell32_hInstance, NameId, wszName, _countof(wszName)))
1207  {
1208  ERR("Failed to load string\n");
1209  return E_FAIL;
1210  }
1211 
1212  /* Init first cmd id and submenu */
1213  m_idCmdFirst = m_idCmdLast = idCmdFirst;
1214  m_hSubMenu = NULL;
1215 
1216  /* If we are going to be default item, we shouldn't be submenu */
1217  if (DefaultPos != -1)
1218  {
1219  /* Load applications list */
1220  m_pAppList->Load();
1222 
1223  /* Create submenu only if there is more than one application and menu has a default item */
1224  if (m_pAppList->GetRecommendedCount() > 1)
1225  {
1227 
1228  for(UINT i = 0; i < m_pAppList->GetCount(); ++i)
1229  {
1230  COpenWithList::SApp *pApp = m_pAppList->GetList() + i;
1231  if (pApp->bRecommended)
1232  AddApp(pApp);
1233  }
1234 
1236  }
1237  }
1238 
1239  /* Insert menu item */
1240  MENUITEMINFOW mii;
1241  ZeroMemory(&mii, sizeof(mii));
1242  mii.cbSize = sizeof(mii);
1243  mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
1244  if (m_hSubMenu)
1245  {
1246  mii.fMask |= MIIM_SUBMENU;
1247  mii.hSubMenu = m_hSubMenu;
1248  mii.wID = -1;
1249  }
1250  else
1251  mii.wID = m_idCmdLast;
1252 
1253  mii.fType = MFT_STRING;
1254  mii.dwTypeData = (LPWSTR)wszName;
1255  mii.cch = wcslen(wszName);
1256 
1257  mii.fState = MFS_ENABLED;
1258  if (DefaultPos == -1)
1259  mii.fState |= MFS_DEFAULT;
1260 
1261  if (!InsertMenuItemW(hMenu, DefaultPos + 1, TRUE, &mii))
1262  return E_FAIL;
1263 
1265 }
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
SApp * GetList()
VOID AddApp(PVOID pApp)
#define _countof(array)
Definition: fontsub.cpp:30
#define ZeroMemory
Definition: winbase.h:1642
LPWSTR dwTypeData
Definition: winuser.h:3243
UINT uFlags
Definition: api.c:59
#define MFS_DEFAULT
Definition: winuser.h:743
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define IDS_OPEN
Definition: resource.h:12
#define SEVERITY_SUCCESS
Definition: winerror.h:64
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
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MFS_ENABLED
Definition: winuser.h:745
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define MIIM_STATE
Definition: winuser.h:716
smooth NULL
Definition: ftsmooth.c:416
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define MIIM_ID
Definition: winuser.h:717
BOOL LoadRecommended(LPCWSTR pwszFilePath)
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MIIM_TYPE
Definition: winuser.h:720
#define ERR(fmt,...)
Definition: debug.h:109
VOID AddChooseProgramItem()
#define IDS_OPEN_WITH
Definition: shresdef.h:126
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
unsigned int UINT
Definition: ndis.h:50
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38
UINT GetRecommendedCount()
UINT WINAPI GetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Member Data Documentation

◆ m_hSubMenu

HMENU COpenWithMenu::m_hSubMenu
private

◆ m_idCmdFirst

UINT COpenWithMenu::m_idCmdFirst
private

Definition at line 35 of file COpenWithMenu.h.

Referenced by COpenWithMenu(), InvokeCommand(), and QueryContextMenu().

◆ m_idCmdLast

UINT COpenWithMenu::m_idCmdLast
private

◆ m_pAppList

COpenWithList* COpenWithMenu::m_pAppList
private

Definition at line 38 of file COpenWithMenu.h.

Referenced by AddApp(), COpenWithMenu(), QueryContextMenu(), and ~COpenWithMenu().

◆ m_wszPath

WCHAR COpenWithMenu::m_wszPath[MAX_PATH]
private

Definition at line 36 of file COpenWithMenu.h.

Referenced by Initialize(), InvokeCommand(), and QueryContextMenu().


The documentation for this class was generated from the following files: