Re: Context Menu in List Control
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Tue, 5 Dec 2006 07:36:38 -0800
I would use code like:
LVHITTESTINFO hitinfo;
//Copy click point
hitinfo.pt = pNMListView->ptAction;
//Make the hit test to see which item we right clicked on
int nItem = m_cList.HitTest(&hitinfo);
And then use SetItemState() to set the state of the item before popping up
the menu. That way you could use the OnInitMenuPopup() function to pump the
command UI messages based on the current selection and use typical
ON_UPDATE_COMMAND_UI handlers to enable or disable menu items.
Tom
<nandan.mehra@xxxxxxxxx> wrote in message
news:1165298831.786466.190630@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I want to create a context menu called by a right mouse click on a
multi-selection List Control in a report mode. So far I've managed to
create the menu by handling NM_RCLICK, like this:
void GetTLETab::OnNMRclickList(NMHDR *pNMHDR, LRESULT *pResult)
{
CMenu menu;
CPoint pt;
::GetCursorPos( &pt);
menu.CreatePopupMenu();
menu.AppendMenu( MF_STRING, 0, _T("Delete this item"));
menu.AppendMenu( MF_STRING, 1, _T("View details"));
menu.TrackPopupMenu( TPM_LEFTALIGN, pt.x, pt.y, this);
*pResult = 0;
}
This displays the context menu correctly. Now I need to
1) find which item was clicked and
2) associate actions with the menu items.
Unfortunately, I have no idea how and where to do that.
I would appreciate any hints.
nandan
.
- References:
- Context Menu in List Control
- From: nandan.mehra@xxxxxxxxx
- Context Menu in List Control
- Prev by Date: Re: Q about Virtual list controls
- Next by Date: Function calling when dialog exit
- Previous by thread: Re: Context Menu in List Control
- Next by thread: Re: Context Menu in List Control
- Index(es):