CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Miami, FL
    Posts
    67

    How to get a menu window's HMENU from its HWND?

    I'm writing an application which uses Windows Hooks to detect when a pop-up menu is about to be displayed as a result of the user right-clicking inside another application. The idea is to disable one of the items in the pop-up menu before it gets displayed to prevent the user from invoking it.

    I've been able to figure out how to intercept the pop-up menu when it comes up by checking for the WM_SHOWWINDOW message and then comparing its window class to "#32768". Unfortunately once I get the window handle (HWND) for it, I don't know how to turn it into a menu handle (HMENU) so I can call ModifyMenu on it. I've tried casting it but it doesn't work (IsMenu fails). Do you know how to go from a menu's HWND to its HMENU?

    I appreciate your help!

    Alvaro

  2. #2
    Join Date
    Apr 1999
    Posts
    396

    Re: How to get a menu window's HMENU from its HWND?

    GetMenu(hWnd) will retrieve the main window. Then you can use that HMENU on subsequent calls to GetSubMenu(...)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured