Pop up menu on Right Click in List view
-
Hi all, Can any one please tell me the code for loading a popup menu on right click on a particular item in a list view. Thanks. Kishore.
-
Hi all, Can any one please tell me the code for loading a popup menu on right click on a particular item in a list view. Thanks. Kishore.
You can use of
NM_RCLICK
event and then load your menu.
WhiteSky
-
You can use of
NM_RCLICK
event and then load your menu.
WhiteSky
I have already tried using the NM_RCLICK event. But the menu is not being loaded for some reason. Please give me a sample code for loadmenu in List view. Kishore
-
I have already tried using the NM_RCLICK event. But the menu is not being loaded for some reason. Please give me a sample code for loadmenu in List view. Kishore
Can you show your code how did you declare it,please?
WhiteSky
-
I have already tried using the NM_RCLICK event. But the menu is not being loaded for some reason. Please give me a sample code for loadmenu in List view. Kishore
Y K Kishore Kumar wrote:
I have already tried using the NM_RCLICK event.
Does this imply that you are handling the
NM_RCLICK
notification? If so, then you should have something like:BEGIN_MESSAGE_MAP(CMyView, CListView)
//{{AFX_MSG_MAP(CMyView)
ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
...
void CMyView::OnRclick(LPNMHDR, LRESULT* pResult)
{
CListCtrl &ctrlList = GetListCtrl();
CPoint pt;
CMenu menu,
*pSubMenu;if (ctrlList.GetNextItem(-1, LVIS\_SELECTED) != -1) { menu.LoadMenu(IDR\_ITEM\_MENU); pSubMenu = menu.GetSubMenu(0); // where was the mouse clicked? pt = GetMessagePos(); pSubMenu->TrackPopupMenu(TPM\_LEFTALIGN, pt.x, pt.y, this); } \*pResult = 0;
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne