Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get the handle of a Popup Menu for a window?

How to get the handle of a Popup Menu for a window?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++databasetoolsjson
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xiangyang Liu
    wrote on last edited by
    #1

    If I high-light some text in a window and right-click the mouse, there will be a popup menu with items like copy, cut, paste, etc. If I know the handle of the window, how to get the handle of the popup menu? I know about the GetMenu API, does it do what I want? This is for a non-MFC app. Please note that I don't want to create a new menu, just needs the handle of the existing popup menu. Thanks.[

    My articles and software tools

    ](http://mysite.verizon.net/XiangYangL/index.htm)

    L R H 3 Replies Last reply
    0
    • X Xiangyang Liu

      If I high-light some text in a window and right-click the mouse, there will be a popup menu with items like copy, cut, paste, etc. If I know the handle of the window, how to get the handle of the popup menu? I know about the GetMenu API, does it do what I want? This is for a non-MFC app. Please note that I don't want to create a new menu, just needs the handle of the existing popup menu. Thanks.[

      My articles and software tools

      ](http://mysite.verizon.net/XiangYangL/index.htm)

      L Offline
      L Offline
      Laxman9
      wrote on last edited by
      #2

      you can use GetMenu api which gives u the main menu handle and then use the getsubmenu passing the menu handle. for creating the popup menu the following link help u.. http://dietmonday.com/windows/WinDoc/msdn/sdk/platforms/doc/sdk/win32/func/src/f88_14.htm Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool: -- modified at 23:34 Tuesday 24th January, 2006

      1 Reply Last reply
      0
      • X Xiangyang Liu

        If I high-light some text in a window and right-click the mouse, there will be a popup menu with items like copy, cut, paste, etc. If I know the handle of the window, how to get the handle of the popup menu? I know about the GetMenu API, does it do what I want? This is for a non-MFC app. Please note that I don't want to create a new menu, just needs the handle of the existing popup menu. Thanks.[

        My articles and software tools

        ](http://mysite.verizon.net/XiangYangL/index.htm)

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        Generally, the menu is created just before it is used and destroyed afterwards (most developers would do it this way), so you can't get a handle to it. Even if it was kept around, there is no API to get its handle because it is not a Windows function - the application takes care of creating and storing it, and just calls TrackPopupMenu() when necessary to display it.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        X 1 Reply Last reply
        0
        • X Xiangyang Liu

          If I high-light some text in a window and right-click the mouse, there will be a popup menu with items like copy, cut, paste, etc. If I know the handle of the window, how to get the handle of the popup menu? I know about the GetMenu API, does it do what I want? This is for a non-MFC app. Please note that I don't want to create a new menu, just needs the handle of the existing popup menu. Thanks.[

          My articles and software tools

          ](http://mysite.verizon.net/XiangYangL/index.htm)

          H Offline
          H Offline
          Hans Ruck
          wrote on last edited by
          #4

          Xiangyang Liu wrote:

          I know the handle of the window

          Then you might subclass the window and handle the WM_INITMENUPOPUP and, maybe, WM_RBUTTONUP messages.


          "quot capita, tot sententiæ" rechi+

          1 Reply Last reply
          0
          • R Ryan Binns

            Generally, the menu is created just before it is used and destroyed afterwards (most developers would do it this way), so you can't get a handle to it. Even if it was kept around, there is no API to get its handle because it is not a Windows function - the application takes care of creating and storing it, and just calls TrackPopupMenu() when necessary to display it.

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            X Offline
            X Offline
            Xiangyang Liu
            wrote on last edited by
            #5

            Ryan Binns wrote:

            the application takes care of creating and storing it, and just calls TrackPopupMenu() when necessary to display it.

            What I want to do is adding some items to the menu, not replacing the menu. The application is not mine, I need to install a hook to get into the application. Currently I am trying other ways. Thanks.[

            My articles and software tools

            ](http://mysite.verizon.net/XiangYangL/index.htm)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups