c++ - Can we execute rightclick without using pCmdInfo->lpVerb -


I am not using agnaist pCmdInfo-> lpVerb but my problem is that we How to handle this situation when we create the rightclick submenus dynamically. For example, I have the following scenario:

  if (strcmp (cRegKeyVal, "connected") == 0) {// g_bConnectStatus = TRUE; InsertMenu (m_hSubmenu, 0, MF_BYPOSITION | MF_GRAYED, M_UCMIDID ++, _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_UCMIDID ++, _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, and mii); }  

Now if I switch code with pCmdInfo-> gt; I am using lpVerb , as shown below, then Case 1 is executing on what I do Disconnect Click the Other menu item ( if is located in the hyper code snippet) or help (As the code snippet inserted in)

  switch (Loword (pCmdInfo-> lpVerb)) {case 0: {// Case-0} Your login for the break; Case 1: {// Your Logic for Case-i} Break; }  

Store the menu item identifier (or offset) in the query context menu needed? For later use in invoke command:

  QueryContextMenu () {m_uConnectId = m_uCmdID ++; InsertMenu (m_hSubMenu, "Connect"); M_uHelpId = m_uCmdID ++; InsertMenu (m_hSubMen, "Help"); } Awake Comm () {ULong UCMDID = Lower (PCMDINFO-> LP Weirb); If (uCmdID == m_uConnectId) {// do "connect"} and if (uCmdID == m_uHelpId) {// do "help"}}  

Comments