Click to See Complete Forum and Search --> : PopUp Menu
Deepa
September 8th, 1999, 08:01 AM
I have a Tree view and list view similar to explorer in a MDI Application. In the List View I have a Popup menu displayed on click of the right mouse button.The problem is if I right click on any label of list view I get the Popup menu for the first time, but then if I click in another Label or same label area of List view I get the menu only in the second mouse click and not in the first click itself.i.e. I get the Popup menu for the first time without any problems but after that I get the Popup menu only after two mouse clicks.Please suggest a solution.
Thomas Ascher
September 10th, 1999, 05:17 AM
Display the menu in response to the window message WM_CONTEXTMENU not in response to mouse click messages.
Praveen
September 10th, 1999, 01:53 PM
You must doing TrackPopupMenu from OnRButtonDown(). That won't work , Instead you add the handler
in OnRClick()
message map looks like
ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
I am sending my code which I am using in ListView to show popup menu on Right click.
void CItbListView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CWnd* pWnd = ((CTestprepApp* )AfxGetApp())->m_pMainWnd;
CPoint point;
GetCursorPos(&point);
CPoint ptTemp = point;
ScreenToClient(&point);
m_pPopupMenu->CreatePopupMenu();
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_ADDCTL ,"Add CTL");
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_REMCTL ,"Remove CTL");
m_pPopupMenu->AppendMenu(MF_SEPARATOR);
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_ADDISC ,"Set ISC");
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_REMISC ,"Remove ISC");
m_pPopupMenu->AppendMenu(MF_SEPARATOR);
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_ADDIGC ,"Set IGC");
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_REMIGC ,"Remove IGC");
m_pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,ptTemp.x,ptTemp.y,pWnd);
m_pPopupMenu->DestroyMenu();
*pResult = 0;
}
PRAVEEN
September 10th, 1999, 01:53 PM
You must doing TrackPopupMenu from OnRButtonDown(). That won't work , Instead you add the handler
in OnRClick()
message map looks like
ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
I am sending my code which I am using in ListView to show popup menu on Right click.
void CItbListView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CWnd* pWnd = ((CTestprepApp* )AfxGetApp())->m_pMainWnd;
CPoint point;
GetCursorPos(&point);
CPoint ptTemp = point;
ScreenToClient(&point);
m_pPopupMenu->CreatePopupMenu();
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_ADDCTL ,"Add CTL");
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_REMCTL ,"Remove CTL");
m_pPopupMenu->AppendMenu(MF_SEPARATOR);
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_ADDISC ,"Set ISC");
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_REMISC ,"Remove ISC");
m_pPopupMenu->AppendMenu(MF_SEPARATOR);
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_ADDIGC ,"Set IGC");
m_pPopupMenu->AppendMenu(MF_STRING ,ID_MENU_ITBLIST_REMIGC ,"Remove IGC");
m_pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,ptTemp.x,ptTemp.y,pWnd);
m_pPopupMenu->DestroyMenu();
*pResult = 0;
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.