Add support for tooltips for system tray icons

Oleg Krylov oleg.krylov at gmail.com
Fri Aug 25 05:00:21 CDT 2006


Hello,

On 8/25/06, James Liggett <jrliggett at cox.net> wrote:
> Add support for tooltips for system tray icons.
>
> This patch partially based on the original systray implementation by Kai Morich <kai.morich at bigfoot.de>.

I've been working on the simmilar patch and I want make several
comments on the patch

> +
> +    /* create icon tooltip */
> +    icon->tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
> +                                   WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
> +                                   CW_USEDEFAULT, CW_USEDEFAULT,
> +                                   CW_USEDEFAULT, CW_USEDEFAULT,
> +                                   icon->window, NULL, NULL, NULL);
>

Why the TTS_NOPREFIX flag is needed? It doesn't seem to be used on windows.

Next, we need to set tooltip max width, primarily to enable multiline
tooltips, as several applications relay on this. The code can be, just
after tooltip creation:
    SendMessageW (icon->tooltip, TTM_SETMAXTIPWIDTH, 0, 400);
On windows width value seem to be dependend on system DPI, but I
haven't found the exact formula yet. 400 is value at the default 96
dpi, so it may be a good starting point.

Then my idea is to create tool just after tooltip creation, and then
in modify icon just change tooltip text if requested. Not sure if it
is a better idea, but it fits better into the existing code. Something
like this:
after tooltip creation creation:
TTTOOLINFOW ti;

    ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    ti.cbSize = sizeof(TTTOOLINFOW);
    ti.uFlags = TTF_SUBCLASS;
    ti.hwnd = icon->window;
    ti.hinst = 0;
    ti.uId = 0;
    ti.lpszText = NULL;
    GetClientRect (icon->window, &ti.rect);
    SendMessageW (icon->tooltip, TTM_ADDTOOLW, 0, (LPARAM)&ti);

and in modify icon:
    if (nid->uFlags & NIF_TIP)
    {
        TTTOOLINFOW ti;

        ZeroMemory (&ti, sizeof(TTTOOLINFOW));
        ti.cbSize = sizeof(TTTOOLINFOW);
        ti.hwnd = icon->window;
        ti.hinst = 0;
        ti.uId = 0;
        ti.lpszText = nid->szTip;

        SendMessageW (icon->tooltip, TTM_UPDATETIPTEXTW, 0, (LPARAM)&ti);
    }



More information about the wine-devel mailing list