Search code examples
delphitaskbartrayicon

Delphi: how to show trayicon balloon without showing taskbar when set to autohide


How can I avoid the taskbar popping up when set to autohide, when using ShowBalloonHint?


Solution

  • The notification area in Windows has a defined behavior. You can wish it behaved differently, but that doesn't change the fact that what you want to do cannot be done.

    Sorry for the inconvience.


    A close workaround would be to create a TOOLTIP window yourself, and position it on the screen near where you think the user's notification area might be:

    • bottom right
    • top right
    • bottom left
    • primary monitor
    • secondary monitor

    That will involve using

    • GetSystemMetrics(SM_CXFULLSCREEN)
    • GetSystemMetrics(SM_CYFULLSCREEN)
    • SystemParametersInfo(SPI_GETWORKAREA)

    Then you create a TOOLTIPS_CLASS window:

        FHandle := CreateWindow(TOOLTIPS_CLASS, PChar(''),
                WS_POPUP or TTS_BALLOON,
                Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),
                Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),
                0, 0, HInstance,
                nil);
    

    Then you would send it the TTM_SETTITLE, TTM_UPDATETIPTEXT, TTM_TRACKPOSITION messages, and finally the big moment: TTM_TRACKACTIVATE:

    enter image description here

    And then sometime later you hide the tooltip with another call to TTM_TRACKACTIVATE.


    You're free to follow Windows user experience guidelines, or you can roll your own.