Add support for tooltips for system tray icons

James Liggett jrliggett at cox.net
Fri Aug 25 13:05:12 CDT 2006


On Fri, 2006-08-25 at 13:00 +0300, Oleg Krylov wrote:

> 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.
I got that from the example on MSDN, but I don't think it's an absolute
must. 
> 
> 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.
Sounds reasonable to me. 
> 
> 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);
>     }
You know, I thought about doing this at first, but I decided against it
because it seemed too repetitive. The way I have it now, it's only one
function. I may consider doing this though; I haven't decided yet. 

Thanks for your feedback,
James





More information about the wine-devel mailing list