开发者

Windows Tooltips with style TTS_BALLOON not shown on some installations

开发者 https://www.devze.com 2023-01-30 16:56 出处:网络
I maintain a Win32 desktop application that shows tooltips. This so far works pretty well on many XP And Windows 7 installations.

I maintain a Win32 desktop application that shows tooltips. This so far works pretty well on many XP And Windows 7 installations.

We now get reports from a few customers that they do not see o开发者_如何学编程ur tool tips. The See a rectangular tooltip (that does not have the TTS_BALLOON attribute. But those created with TTS_BALLOON are not visible. The log files sent by a customer report that CreateWindowEx returns a valid windows handle as well as the coordinates and string contained are correct. The machine concerned runs Windows XP and is updated regularly.

Has anybody encountered a similar behavior?

How can we solve this problem?

Source Code:

    gHintInfo.hwnd = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
                            WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, 
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            NULL, NULL, 
                            (HINSTANCE)xvt_vobj_get_attr(TASK_WIN, ATTR_WIN_INSTANCE),
                            NULL);

Trace(1, "\n### DrawHint %d, hwnd = %08x, Text =\n%s\n###\n\n", __LINE__, gHintInfo.hwnd, tx);

    if (gHintInfo.hwnd != NULL)
    {
        TOOLINFO ti;
        ti.cbSize = sizeof (ti);
        ti.uFlags = TTF_TRANSPARENT | TTF_ABSOLUTE;
        ti.hwnd = hwndParent;
        ti.uId = 0;
        ti.hinst = NULL;
        ti.lpszText = (char *) tx;
        GetClientRect (hwndParent, &ti.rect);

dbgrct(ti.rect);
dbgpnt(gHintInfo.LastHintLoc);

        SendMessage(gHintInfo.hwnd, TTM_TRACKPOSITION,0, MAKELONG(gHintInfo.LastHintLoc.v, gHintInfo.LastHintLoc.h));    
        SendMessage (gHintInfo.hwnd, TTM_ADDTOOL, 0, (long) &ti);
        SendMessage (gHintInfo.hwnd, TTM_SETDELAYTIME, TTDT_AUTOMATIC, -1);
        SendMessage (gHintInfo.hwnd, TTM_SETMAXTIPWIDTH, 0, 500);    
        SendMessage (gHintInfo.hwnd, TTM_TRACKACTIVATE, TRUE, (long) &ti);
    }

The log output created by this code on the machine that does not diesplay the tooltips is:

### DrawHint 474, hwnd = 00090112, Text =
Some text with 
multiple lines
###

ti.rect left = 0, top = 0, right = 1280, bottom = 978
gHintInfo.LastHintLoc h = 295, v = 539

(We set ti.rect to the coordiantes of the whole screen, as windows resizes the tool tip to the containing text anyway.)

EDIT: We actually added a configuration property to our Software that does nothing more than adding or removing the TTS_BALLOON attribute. This solves the problem on the machines concerned.


The best solution can be found here.

To disable the tooltip balloon, set EnableBalloonTips to 1

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号