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. TrackPopupMenu

TrackPopupMenu

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 3 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.
  • T Offline
    T Offline
    tom groezer
    wrote on last edited by
    #1

    According to the KB article Q135788 the below code is the correction action that is to be applied to have the TrackPopupMenu to behave accurately. Could somebody explain the problem better and provide a deeper understanding? What is the significance of sending WM_NULL message? SetForegroundWindow(hDlg); // Display the menu TrackPopupMenu( hSubMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL); PostMessage(hDlg, WM_NULL, 0, 0);

    R S 2 Replies Last reply
    0
    • T tom groezer

      According to the KB article Q135788 the below code is the correction action that is to be applied to have the TrackPopupMenu to behave accurately. Could somebody explain the problem better and provide a deeper understanding? What is the significance of sending WM_NULL message? SetForegroundWindow(hDlg); // Display the menu TrackPopupMenu( hSubMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL); PostMessage(hDlg, WM_NULL, 0, 0);

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Posting the null message to the popup menu's owner window forces a task switch to the application that displayed the menu. WM_NULL is chosen as it's a benign message that doesn't do anything more than cause the task switch. /ravi

      This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • T tom groezer

        According to the KB article Q135788 the below code is the correction action that is to be applied to have the TrackPopupMenu to behave accurately. Could somebody explain the problem better and provide a deeper understanding? What is the significance of sending WM_NULL message? SetForegroundWindow(hDlg); // Display the menu TrackPopupMenu( hSubMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL); PostMessage(hDlg, WM_NULL, 0, 0);

        S Offline
        S Offline
        sps itsec46
        wrote on last edited by
        #3

        if i understood your question correctly, the according KB article in MSDN describes why this workaround is necessary: PRB: Menus for Notification Icons Do Not Work Correctly[^]

        SYMPTOMS
        ...
        When you display a context menu for a notification icon (see Shell_NotifyIcon),
        clicking anywhere besides the menu or the window that created the menu
        (if it is visible) doesn't cause the menu to disappear.
        ...

        RESOLUTION
        ...
        The second problem is caused by a problem with TrackPopupMenu. It is necessary
        to force a task switch to the application that called TrackPopupMenu at some
        time in the near future. This can be accomplished by posting a benign message
        to the window or thread.
        ...

        So the WM_NULL message is used to force a task switch to the calling app, so when you click outside the popup menu, the popup menu disappears correctly.

        cheers, mykel OMM: "Let us be thankful we have commerce. Buy more. Buy more now. Buy. And be happy."

        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