Click to See Complete Forum and Search --> : Context Menus


Andrew Truckle
March 29th, 1999, 10:03 AM
I have a dialog based application with support for the context menu when you right-click on the dialog.


At the moment it comes up with a cut/copy/paste menu. The problem is that this menu displays absolutely anywhere on the window, which is wrong.


I only want it to display if it is on the IDC_CONFIG_GRID control. I assume I have to use the passed Cwnd variable in some way.


I am desperate for someones help.


Please email me either on this address or:

andrew@atruckle.freeserve.co.uk


Thanks for your help!

Bob
March 29th, 1999, 10:15 AM
sounds like you need to adding some mouse tracking. How about:

void CBlahDlg::OnContextMenu(CWnd* pWnd, CPoint point)

{

CMenu menu;

CMenu* pSubmenu;

menu.LoadMenu(IDR_MENU1);

pSubmenu = menu.GetSubMenu(0);

pSubmenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, AfxGetApp()->m_pMainWnd,NULL);



}

Andrew Truckle
March 29th, 1999, 01:15 PM
Hi,


Thanks for the advice.


I found this works:


if(pWnd->GetDlgCtrlID() == IDC_CONFIG_GRID)

{

...

...

}