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. Opening system menu with code don’t work

Opening system menu with code don’t work

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpcom
3 Posts 2 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.
  • P Offline
    P Offline
    Patric_J
    wrote on last edited by
    #1

    Hi, I want to open the system menu of a window from code instead of as usual letting the user do it by right mouse-clicking on the top left icon. I use GetSystemMenu() to get the system menu and TrackPopupMenu() to display it. The system menu shows up but when I click on any menu item, nothing is routed back to the window. OnSysCommand() which normally receives system menu clicks is not called. However if the system menu is opened by the user as usual, everything works fine. What do I do wrong? How do I trap the menu item clicks? Here’s the code from my test project, a standard dialog based application, TestDlg inherits from CDialog so this pointer is the dialog itself with the OnSysCommand() method. void TestDlg::OnButton() { CMenu* pSysMenu = GetSystemMenu(FALSE); pSysMenu->TrackPopupMenu(0, 100, 100, this); } /Thanks, Patric /Patric My C# blog: C# Coach

    G 1 Reply Last reply
    0
    • P Patric_J

      Hi, I want to open the system menu of a window from code instead of as usual letting the user do it by right mouse-clicking on the top left icon. I use GetSystemMenu() to get the system menu and TrackPopupMenu() to display it. The system menu shows up but when I click on any menu item, nothing is routed back to the window. OnSysCommand() which normally receives system menu clicks is not called. However if the system menu is opened by the user as usual, everything works fine. What do I do wrong? How do I trap the menu item clicks? Here’s the code from my test project, a standard dialog based application, TestDlg inherits from CDialog so this pointer is the dialog itself with the OnSysCommand() method. void TestDlg::OnButton() { CMenu* pSysMenu = GetSystemMenu(FALSE); pSysMenu->TrackPopupMenu(0, 100, 100, this); } /Thanks, Patric /Patric My C# blog: C# Coach

      G Offline
      G Offline
      GKarRacer
      wrote on last edited by
      #2

      Try this instead:

      void TestDlg::OnButton()
      {
      SendMessage( WM_SYSCHAR, VK_SPACE, 0x20000000 );
      }

      P 1 Reply Last reply
      0
      • G GKarRacer

        Try this instead:

        void TestDlg::OnButton()
        {
        SendMessage( WM_SYSCHAR, VK_SPACE, 0x20000000 );
        }

        P Offline
        P Offline
        Patric_J
        wrote on last edited by
        #3

        Thanks, it works. /Patric My C# blog: C# Coach

        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