ReactOS  0.4.15-dev-5142-g967f5b9
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 1097 of file COpenWithMenu.cpp.

1098 {
1099  m_idCmdFirst = 0;
1100  m_idCmdLast = 0;
1101  m_pAppList = new COpenWithList;
1102 }
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38

◆ ~COpenWithMenu()

COpenWithMenu::~COpenWithMenu ( )

Definition at line 1104 of file COpenWithMenu.cpp.

1105 {
1106  TRACE("Destroying COpenWithMenu(%p)\n", this);
1107 
1108  if (m_hSubMenu)
1109  {
1110  INT Count, Index;
1111  MENUITEMINFOW mii;
1112 
1113  /* get item count */
1115  if (Count == -1)
1116  return;
1117 
1118  /* setup menuitem info */
1119  ZeroMemory(&mii, sizeof(mii));
1120  mii.cbSize = sizeof(mii);
1122 
1123  for(Index = 0; Index < Count; Index++)
1124  {
1125  if (GetMenuItemInfoW(m_hSubMenu, Index, TRUE, &mii))
1126  {
1127  if (mii.hbmpChecked)
1129  }
1130  }
1131  }
1132 
1133  if (m_pAppList)
1134  delete m_pAppList;
1135 }
#define MIIM_FTYPE
Definition: winuser.h:724
HBITMAP hbmpChecked
Definition: winuser.h:3256
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1667
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int32_t INT
Definition: typedefs.h:58
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
int Count
Definition: noreturn.cpp:7
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define TRACE(s)
Definition: solgame.cpp:4
_In_ WDFCOLLECTION _In_ ULONG Index
#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 1188 of file COpenWithMenu.cpp.

1189 {
1190  MENUITEMINFOW mii;
1191  LPCWSTR pwszName = m_pAppList->GetName((COpenWithList::SApp*)pApp);
1192 
1193  ZeroMemory(&mii, sizeof(mii));
1194  mii.cbSize = sizeof(mii);
1196  mii.fType = MFT_STRING;
1197  mii.fState = MFS_ENABLED;
1198  mii.wID = m_idCmdLast;
1199  mii.dwTypeData = (LPWSTR)pwszName;
1200  mii.cch = wcslen(mii.dwTypeData);
1201  mii.dwItemData = (ULONG_PTR)pApp;
1202 
1204  if (hIcon)
1205  {
1206  mii.fMask |= MIIM_CHECKMARKS;
1208  }
1209 
1210  if (InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii))
1211  m_idCmdLast++;
1212 }
static HICON
Definition: imagelist.c:84
#define MFT_STRING
Definition: winuser.h:741
HBITMAP hbmpChecked
Definition: winuser.h:3256
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
HBITMAP IconToBitmap(HICON hIcon)
#define ZeroMemory
Definition: winbase.h:1667
LPWSTR dwTypeData
Definition: winuser.h:3259
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)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38
#define ULONG_PTR
Definition: config.h:101
HBITMAP hbmpUnchecked
Definition: winuser.h:3257
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
ULONG_PTR dwItemData
Definition: winuser.h:3258

Referenced by QueryContextMenu().

◆ AddChooseProgramItem()

VOID COpenWithMenu::AddChooseProgramItem ( )
private

Definition at line 1160 of file COpenWithMenu.cpp.

1161 {
1162  MENUITEMINFOW mii;
1163  WCHAR wszBuf[128];
1164 
1165  ZeroMemory(&mii, sizeof(mii));
1166  mii.cbSize = sizeof(mii);
1167  mii.fMask = MIIM_TYPE | MIIM_ID;
1168  mii.fType = MFT_SEPARATOR;
1169  mii.wID = -1;
1170  InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii);
1171 
1173  {
1174  ERR("Failed to load string\n");
1175  return;
1176  }
1177 
1178  mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
1179  mii.fType = MFT_STRING;
1180  mii.fState = MFS_ENABLED;
1181  mii.wID = m_idCmdLast;
1182  mii.dwTypeData = (LPWSTR)wszBuf;
1183  mii.cch = wcslen(wszBuf);
1184 
1185  InsertMenuItemW(m_hSubMenu, -1, TRUE, &mii);
1186 }
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1667
LPWSTR dwTypeData
Definition: winuser.h:3259
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
#define IDS_OPEN_WITH_CHOOSE
Definition: shresdef.h:135
#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)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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 1331 of file COpenWithMenu.cpp.

1333 {
1334  FIXME("%p %lu %u %p %p %u\n", this,
1335  idCmd, uType, pwReserved, pszName, cchMax );
1336 
1337  return E_NOTIMPL;
1338 }
#define FIXME(fmt,...)
Definition: debug.h:111
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 1340 of file COpenWithMenu.cpp.

1344 {
1345  TRACE("This %p uMsg %x\n", this, uMsg);
1346 
1347  return E_NOTIMPL;
1348 }
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 1137 of file COpenWithMenu.cpp.

1138 {
1139  HDC hdc, hdcScr;
1140  HBITMAP hbm, hbmOld;
1141  RECT rc;
1142 
1143  hdcScr = GetDC(NULL);
1144  hdc = CreateCompatibleDC(hdcScr);
1146  hbm = CreateCompatibleBitmap(hdcScr, rc.right, rc.bottom);
1147  ReleaseDC(NULL, hdcScr);
1148 
1149  hbmOld = (HBITMAP)SelectObject(hdc, hbm);
1150  FillRect(hdc, &rc, (HBRUSH)(COLOR_MENU + 1));
1151  if (!DrawIconEx(hdc, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
1152  ERR("DrawIcon failed: %x\n", GetLastError());
1153  SelectObject(hdc, hbmOld);
1154 
1155  DeleteDC(hdc);
1156 
1157  return hbm;
1158 }
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:1025
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
LONG right
Definition: windef.h:308
#define SM_CYMENUCHECK
Definition: winuser.h:1026
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define COLOR_MENU
Definition: winuser.h:911
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:110
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
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
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 1351 of file COpenWithMenu.cpp.

1354 {
1355  LPCITEMIDLIST pidlFolder2;
1356  LPCITEMIDLIST pidlChild;
1357 
1358  TRACE("This %p\n", this);
1359 
1360  if (pdtobj == NULL)
1361  return E_INVALIDARG;
1362 
1363  CDataObjectHIDA pida(pdtobj);
1364  if (FAILED(pida.hr()))
1365  {
1366  ERR("pdtobj->GetData failed with 0x%x\n", pida.hr());
1367  return pida.hr();
1368  }
1369 
1370  ASSERT(pida->cidl >= 1);
1371 
1372  pidlFolder2 = HIDA_GetPIDLFolder(pida);
1373  pidlChild = HIDA_GetPIDLItem(pida, 0);
1374 
1375  if (!_ILIsValue(pidlChild))
1376  {
1377  TRACE("pidl is not a file\n");
1378  return E_FAIL;
1379  }
1380 
1381  CComHeapPtr<ITEMIDLIST> pidl(ILCombine(pidlFolder2, pidlChild));
1382  if (!pidl)
1383  {
1384  ERR("no mem\n");
1385  return E_OUTOFMEMORY;
1386  }
1387 
1388  if (!SHGetPathFromIDListW(pidl, m_wszPath))
1389  {
1390  ERR("SHGetPathFromIDListW failed\n");
1391  return E_FAIL;
1392  }
1393 
1394  TRACE("szPath %s\n", debugstr_w(m_wszPath));
1395 
1397  if (PathIsExeW(pwszExt) || !_wcsicmp(pwszExt, L".lnk"))
1398  {
1399  TRACE("file is a executable or shortcut\n");
1400  return E_FAIL;
1401  }
1402 
1403  return S_OK;
1404 }
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
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:1294
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:554
#define E_FAIL
Definition: ddrawi.h:102
#define L(x)
Definition: ntvdm.h:50
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
EXTERN_C BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:370
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:1985
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:549
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ InvokeCommand()

HRESULT WINAPI COpenWithMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
virtual

Implements IContextMenu.

Definition at line 1289 of file COpenWithMenu.cpp.

1290 {
1291  HRESULT hr = E_FAIL;
1292 
1293  TRACE("This %p idFirst %u idLast %u idCmd %u\n", this, m_idCmdFirst, m_idCmdLast, m_idCmdFirst + LOWORD(lpici->lpVerb));
1294 
1295  if (HIWORD(lpici->lpVerb) == 0 && m_idCmdFirst + LOWORD(lpici->lpVerb) <= m_idCmdLast)
1296  {
1297  if (m_idCmdFirst + LOWORD(lpici->lpVerb) == m_idCmdLast)
1298  {
1299  OPENASINFO info;
1301 
1302  info.pcszFile = m_wszPath;
1303  info.oaifInFlags = OAIF_EXEC;
1304  if (pwszExt[0])
1306  info.pcszClass = NULL;
1307  hr = SHOpenWithDialog(lpici->hwnd, &info);
1308  }
1309  else
1310  {
1311  /* retrieve menu item info */
1312  MENUITEMINFOW mii;
1313  ZeroMemory(&mii, sizeof(mii));
1314  mii.cbSize = sizeof(mii);
1315  mii.fMask = MIIM_DATA | MIIM_FTYPE;
1316 
1317  if (GetMenuItemInfoW(m_hSubMenu, LOWORD(lpici->lpVerb), TRUE, &mii) && mii.dwItemData)
1318  {
1319  /* launch item with specified app */
1322  hr = S_OK;
1323  }
1324  }
1325  }
1326 
1327  return hr;
1328 }
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
#define MIIM_FTYPE
Definition: winuser.h:724
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1667
#define E_FAIL
Definition: ddrawi.h:102
static struct _test_info info[]
Definition: SetCursorPos.c:19
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
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:79
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
#define HIWORD(l)
Definition: typedefs.h:247
#define MIIM_DATA
Definition: winuser.h:721
ULONG_PTR dwItemData
Definition: winuser.h:3258
#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 1214 of file COpenWithMenu.cpp.

1220 {
1221  TRACE("hMenu %p indexMenu %u idFirst %u idLast %u uFlags %u\n", hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
1222 
1223  INT DefaultPos = GetMenuDefaultItem(hMenu, TRUE, 0);
1224 
1225  WCHAR wszName[100];
1226  UINT NameId = (DefaultPos == -1 ? IDS_OPEN : IDS_OPEN_WITH);
1227  if (!LoadStringW(shell32_hInstance, NameId, wszName, _countof(wszName)))
1228  {
1229  ERR("Failed to load string\n");
1230  return E_FAIL;
1231  }
1232 
1233  /* Init first cmd id and submenu */
1234  m_idCmdFirst = m_idCmdLast = idCmdFirst;
1235  m_hSubMenu = NULL;
1236 
1237  /* If we are going to be default item, we shouldn't be submenu */
1238  if (DefaultPos != -1)
1239  {
1240  /* Load applications list */
1241  m_pAppList->Load();
1243 
1244  /* Create submenu only if there is more than one application and menu has a default item */
1245  if (m_pAppList->GetRecommendedCount() > 1)
1246  {
1248 
1249  for(UINT i = 0; i < m_pAppList->GetCount(); ++i)
1250  {
1251  COpenWithList::SApp *pApp = m_pAppList->GetList() + i;
1252  if (pApp->bRecommended)
1253  AddApp(pApp);
1254  }
1255 
1257  }
1258  }
1259 
1260  /* Insert menu item */
1261  MENUITEMINFOW mii;
1262  ZeroMemory(&mii, sizeof(mii));
1263  mii.cbSize = sizeof(mii);
1264  mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
1265  if (m_hSubMenu)
1266  {
1267  mii.fMask |= MIIM_SUBMENU;
1268  mii.hSubMenu = m_hSubMenu;
1269  mii.wID = -1;
1270  }
1271  else
1272  mii.wID = m_idCmdLast;
1273 
1274  mii.fType = MFT_STRING;
1275  mii.dwTypeData = (LPWSTR)wszName;
1276  mii.cch = wcslen(wszName);
1277 
1278  mii.fState = MFS_ENABLED;
1279  if (DefaultPos == -1)
1280  mii.fState |= MFS_DEFAULT;
1281 
1282  if (!InsertMenuItemW(hMenu, DefaultPos + 1, TRUE, &mii))
1283  return E_FAIL;
1284 
1286 }
WCHAR m_wszPath[MAX_PATH]
Definition: COpenWithMenu.h:36
#define MFT_STRING
Definition: winuser.h:741
SApp * GetList()
VOID AddApp(PVOID pApp)
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1667
LPWSTR dwTypeData
Definition: winuser.h:3259
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:58
#define IDS_OPEN
Definition: resource.h:12
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MIIM_SUBMENU
Definition: winuser.h:718
#define MFS_ENABLED
Definition: winuser.h:745
#define MIIM_STATE
Definition: winuser.h:716
#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 _countof(array)
Definition: sndvol32.h:68
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
#define MIIM_TYPE
Definition: winuser.h:720
#define ERR(fmt,...)
Definition: debug.h:110
#define shell32_hInstance
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
VOID AddChooseProgramItem()
#define IDS_OPEN_WITH
Definition: shresdef.h:134
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
COpenWithList * m_pAppList
Definition: COpenWithMenu.h:38
UINT GetRecommendedCount()
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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: