本文整理汇总了C++中LPCONTEXTMENU::GetCommandString方法的典型用法代码示例。如果您正苦于以下问题:C++ LPCONTEXTMENU::GetCommandString方法的具体用法?C++ LPCONTEXTMENU::GetCommandString怎么用?C++ LPCONTEXTMENU::GetCommandString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPCONTEXTMENU
的用法示例。
在下文中一共展示了LPCONTEXTMENU::GetCommandString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecCommand
BOOL CRecBinViewer::ExecCommand (LPCONTEXTMENU pCtxMenu, LPCTSTR lpszCommand)
{
UINT uiID = UINT (-1);
UINT uiCommand = 0;
UINT uiMenuFirst = 1;
UINT uiMenuLast = 0x00007FFF;
HMENU hmenuCtx;
int iMenuPos = 0;
int iMenuMax = 0;
TCHAR szMenuItem[MAX_PATH];
TCHAR verb[MAX_PATH] ;
hmenuCtx = CreatePopupMenu();
HRESULT hr = pCtxMenu->QueryContextMenu(hmenuCtx, 0, uiMenuFirst, uiMenuLast, CMF_NORMAL);
iMenuMax = GetMenuItemCount(hmenuCtx);
for (iMenuPos = 0 ; iMenuPos < iMenuMax; iMenuPos++)
{
GetMenuString(hmenuCtx, iMenuPos, szMenuItem, MAX_PATH, MF_BYPOSITION) ;
uiID = GetMenuItemID(hmenuCtx, iMenuPos) ;
if ((uiID == -1) || (uiID == 0))
{
}
else
{
hr = pCtxMenu->GetCommandString(uiID - 1, GCS_VERB, NULL, (LPSTR)verb, MAX_PATH);
if (FAILED (hr))
{
verb[0] = TCHAR ('\0') ;
}
else
{
if (0 == _tcsicmp (verb, lpszCommand))
uiCommand = uiID - 1;
}
}
}
if ((UINT)-1 != uiCommand)
{
CMINVOKECOMMANDINFO cmi;
ZeroMemory(&cmi, sizeof(CMINVOKECOMMANDINFO));
cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
cmi.fMask = CMIC_MASK_FLAG_NO_UI;
cmi.hwnd = m_hWnd;
cmi.lpVerb = (LPSTR)MAKEINTRESOURCE (uiCommand);
cmi.nShow = SW_SHOWNORMAL;
hr = pCtxMenu->InvokeCommand(&cmi);
if (SUCCEEDED (hr))
return TRUE;
}
return false;
}