May 2, 2010 at 8:46am UTC
EDIT: I have another question. I created a popup menu:
1 2 3 4 5 6 7 8 9 10
// ....
else if (((LPNMHDR)lParam)->code == NM_RCLICK)
{
HMENU hPopupMenu = CreatePopupMenu();
InsertMenu(hPopupMenu, 0, MF_BYPOSITION | MF_STRING, IDCANCEL, (LPCSTR)"Cancel" );
InsertMenu(hPopupMenu, 0, MF_BYPOSITION | MF_STRING, IDB_DELETE, (LPCSTR)"Delete" );
SetForegroundWindow(hwnd);
TrackPopupMenu(hPopupMenu, TPM_BOTTOMALIGN | TPM_LEFTALIGN, 0, 0, 0, hwnd, NULL);
}
The problem that it appears on upper left corner of screen and I want it to appear under mouse cursor. How can I do this?
Last edited on May 2, 2010 at 9:08am UTC
May 2, 2010 at 10:47am UTC
TrackPopupMenu(hPopupMenu, TPM_BOTTOMALIGN | TPM_LEFTALIGN,
0 ,
0 , 0, hwnd, NULL);
In the
TrackPopupMenu function, the x and y position cor-ordinates are relative to
the screen - not the window.
So the 0,0 in your call will put it at the very top left of the screen.
If you want it at the mouse co-ordinates, then if you don't have the mouse position to hand, then use this function
GetCursorPos Function .
See here:
http://msdn.microsoft.com/en-us/library/ms648390%28VS.85%29.aspx
Last edited on May 2, 2010 at 10:54am UTC