Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup (Context) Menu Problem

Status
Not open for further replies.

MorganGreylock

Programmer
Jan 30, 2001
223
US
Hello,

I'm using the 'Learn Visual C++ in 21 Days' Book (day 6)
and here's my problem code:

Code:
	CMenu *m_lMenu;
	CPoint m_pPoint;
    

	m_pPoint = point;

	ClientToScreen(&m_pPoint);
	m_lMenu = GetMenu();
	m_lMenu = m_lMenu->GetSubMenu(0);
	m_lMenu->TrackPopupMenu(TPM_CENTERALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
		m_pPoint.x, m_pPoint.y, this, NULL);

The context menu is popping up, but always in the wrong
spot. Its always lower and more right than my window. If
I move my cursor and right-click again, the popup menu
moves the same distance from the original location, but
still in the wrong place.

In other words, it just seems that there is a number being
added to the x and y coordinates of the point.

The book says to use GetMenu(), although I've seen
references to LoadMenu() in this forum. Is there a reason
to use one over the other?

Much appreciated,
MG
 
I've also noticed the following:

When I put my dialog at the top left of the screen and
right click in the top left of the dialog (very corner)
its very close to where it should be, and the exact
opposite is true for the bottom right (ie the further
bottom-right I go, the more off it is). That sounds to
me like a scaling problem. I'm running at 1600x1200. Is it
possible that MFC can't handle it at the resolution or
something like that?

Thanks,
MG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top