我不反对使用pCmdInfo->lpVerb
,但我的问题是当我们动态创建右键单击子菜单时我们将如何处理这种情况。例如,我有以下场景:
if(strcmp(cRegKeyVal,"Connected")==0)
{
//g_bConnectStatus=TRUE;
InsertMenu ( m_hSubmenu , 0, MF_BYPOSITION|MF_GRAYED, m_uCmdID++, _T("Connect") );
InsertMenu ( m_hSubmenu , 1, MF_BYPOSITION, m_uCmdID++, _T("DicConnect") );
InsertMenu ( m_hSubmenu , 2, MF_BYPOSITION, m_uCmdID++, _T("Configure") );
InsertMenu ( m_hSubmenu , 3, MF_BYPOSITION, m_uCmdID++, _T("Menu4") );
InsertMenu ( m_hSubmenu , 4, MF_BYPOSITION, m_uCmdID++, _T("About") );
}
else
{
//g_bConnectStatus=FALSE;
InsertMenu ( m_hSubmenu , 0, MF_BYPOSITION, m_uCmdID++, _T("Connect") );
InsertMenu ( m_hSubmenu , 3, MF_BYPOSITION, m_uCmdID++, _T("Help") );
InsertMenu ( m_hSubmenu , 4, MF_BYPOSITION, m_uCmdID++, _T("About") );
}
..
..
InsertMenuItem ( hmenu, uMenuIndex, TRUE, &mii );
}
现在,如果我使用pCmdInfo->lpVerb
switch case ,如下所示,那么Case 1
无论我点击DisConnect
(在上面的代码片段中的 If条件中插入的Help
菜单项)还是(在上面的代码片段中的其他部分插入的菜单项),都将被执行
switch ( LOWORD( pCmdInfo->lpVerb) )
{
case 0:
{
//Your Logi for Case-0
}
break;
case 1:
{
//Your Logi for Case-I
}
break;
}