Hi folks,
I have a problem with a program I have constructed as a lesson in Sams Visual C++ in 21 days. The problem is with the method for the event handler for a pop up menu and the function OnContextMenu. The program compiles and links okay, and works as per the book up until I right click anywhere in the dialog to display the pop up menu. The menu appears not where the mouse was clicked, but further down 45 degrees to the right of the mouse.
Does anyone know what is wrong. The code is as in the book...?
Code:
void CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{
// declare local variables
CMenu *m_lMenu; // pointer to the menu
CPoint m_pPoint; // copy of the mouse position
// copy the mouse position to a local variable
m_pPoint = point;
// convert position to a screen position
ClientToScreen(&m_pPoint);
// get a pointer to the window menu
m_lMenu = GetMenu();
// get a pointer to the first submenu
m_lMenu = m_lMenu->GetSubMenu(0);
// show the Pop Up Menu
m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON,
m_pPoint.x, m_pPoint.y, this, NULL);
}
system is Win98SE and compiler is msvc++ v.6.