locked
Notification Area Flyout Positioning RRS feed

  • Question

  • I'm updating a simple C++ application (no managed code, no MFC) that uses a notification area icon.  I'm adding a notification area flyout window, as suggested in the Windows User Experience Interaction Guidelines (http://msdn.microsoft.com/en-us/library/aa511448.aspx#flyouts).  The guidelines suggest that the flyout window be displayed "near the associated icon".  I'm having trouble figuring out the coordinates of the icon, since that is controlled by Windows and not by my code.  And I also need to figure out where the notification area is displayed (along the bottom of the screen, on the left side of the screen, etc.) so I can determine whether to display my flyout window above it, to the right of it, etc.  I would appreciate any pointers on how to go about this.  Thanks in advance.
    Tuesday, February 2, 2010 8:34 PM

Answers

  • Hello

    Before Windows 7, you may consider this solution:

    1. get the window handle of taskbar
    2. get the position and the size (width and height) of the taskbar (GetWindowRect)
    3. determine whether the taskbar is at the bottom / top / left / right of the screen
    4. For example, if it's at the bottom, the Y axis of your flyout window is screen height - taskbar height - flyout window height. And its X axis could be tuned according to the current mouse location.

    You may also consider ignoring taskbar size, and calculating the flyout window position based on the mouse location and the screen size.
    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by BradVoy Tuesday, February 9, 2010 2:13 PM
    Thursday, February 4, 2010 8:23 AM

All replies

  • Can you just use the Shell_NotifyIcon function and let it handle the placement of the window for you?
    http://msdn.microsoft.com/en-us/library/ee330740(VS.85).aspx


    Tuesday, February 2, 2010 11:14 PM
  • Shell_NotifyIcon can be used to display the notification area icon itself and a notification balloon (also referred to as a rich tooltip).  But as far as I can tell from the article you pointed me to and other reading Shell_NotifyIcon can't display a notification flyout window.  http://msdn.microsoft.com/en-us/library/aa511448.aspx explains the difference between these.
    Tuesday, February 2, 2010 11:32 PM
  • I just re-read the article Eric pointed me to and saw that it does provide a partial answer to my question.  It recommends using the  CalculatePopupWindowPosition function to determine where to place the notification area flyout window.  Unfortunately that function is only available on Windows 7, and my solution has to support Windows XP and Vista.  Any other ideas?
    Wednesday, February 3, 2010 10:54 PM
  • Hello

    Before Windows 7, you may consider this solution:

    1. get the window handle of taskbar
    2. get the position and the size (width and height) of the taskbar (GetWindowRect)
    3. determine whether the taskbar is at the bottom / top / left / right of the screen
    4. For example, if it's at the bottom, the Y axis of your flyout window is screen height - taskbar height - flyout window height. And its X axis could be tuned according to the current mouse location.

    You may also consider ignoring taskbar size, and calculating the flyout window position based on the mouse location and the screen size.
    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by BradVoy Tuesday, February 9, 2010 2:13 PM
    Thursday, February 4, 2010 8:23 AM
  • This sounds like the right approach.  But I don't know how to do step 1 (get the window handle of the taskbar).  Can you give me details on that?

    Thanks for your help!

    Thursday, February 4, 2010 3:20 PM

  • Use Microsoft Spy++ to find the Window.

    The Caption is empty and the Class is "Shell_TrayWnd".  Then call FindWindow to get the handle.

    Thursday, February 4, 2010 3:57 PM
  • Thank you, Eric.

    Hi Brad,

    If you have any other questions, please feel free to post here.
    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, February 9, 2010 4:56 AM
  • The two of you fully answered my questions.  Thanks for your help.
    Tuesday, February 9, 2010 2:13 PM