For CMenu of MFC, normally we will use member function "BOOL TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = NULL )" to pop up menu, here the parameter "CWnd* pWnd" identifies the window that owns the pop-up menu. So how could I get the owner window "pWnd" when I only have a got a pointer of CMenu?
Following are codes that get the menu, and how to get the owner window of menu?
CWnd *pMenuWindow = CWnd::FromHandle(::GetTopWindow());// Get the menu window
HMENU hMenu = (HMENU)(pMenuWindow->SendMessage(MN_GETHMENU, 0, 0));
CMenu *pPopupMenu = CMenu::FromHandle(hMenu);// Get the menu
......... // Here how to get the owner of pPopupMenu? (means parameter pWnd which is used when call TrackPopupMenu)
// if call pMenuWindow->GetParent(), it is NULL, so this way is impossible to get the message owner of CMenu window