popup menu


I'm developing a MDI application and need to display
a floating menu calling TrackPopupMenu (..) at a location
relative to the top left corner of the view ( not the child frame)
How should I modify the coordinates to do this.By default,
the position is always relative to tte main frame window.

Thanks.
e6694811Asked:
Who is Participating?
 
abancroftCommented:
Great!
0
 
PIGCommented:
CRect rect;
view->GetClientRect(&rect);
AfxGetApp()->GetMAinWnd()->ScreenToClient(&rect);
ret.left, rect.top is location for top left corrner of the client window.

And
CRect rect;
view->GetWindowRect(&rect);
AfxGetApp()->GetMAinWnd()->ScreenToClient(&rect);
ret.left, rect.top is location for top left corrner of the miniframe.
0
 
e6694811Author Commented:

 Hmm.It does not seem to work because the location
obtained is not the desired .For example ,if call Trackpopup menu with p.x =p.y =0 , the top-left corner of the floating menu
should be located at the top-left corner of the wiew .
0
 
abancroftCommented:
The help says TrackPopupMenu() uses SCREEN co-ords. So 0,0 should be located at the top left of the screen.

On that assumption, here's code to display the menu at the top left of the view:
CRect rect;
view->GetWindowRect(&rect);
menu->TrackPopupMenu(TPM_LEFTALIGN, rect.left, rect.top, view, NULL);
0
 
e6694811Author Commented:

 It worked .Send an anwer so that I can grade your response
an give the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.