Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

How to get the message owner of CMenu window?

$
0
0

    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



Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>