changing tooltip font using 'SendMessage ... WM_SETFONT' results in underlined text in tooltip RRS feed

  • Question

  • I am trying to write an ahk script to programmatically change the tooltip font for a particular application. I am able to accomplish this with one caveat: no matter what I set the font to, all text in the tooltip is underlined. If I create a Tooltip from within the ahk script and modify its font, it works as planned without underlined text.

    Here is the ahk script:

    SetTimer TooltipFinder, 50
    hFont := CreateFont("bold italic s24", "Arial")
      IfWInExist ahk_class tooltips_class32
        WinGet, tooltipID, ID
        SendMessage, WM_SETFONT, hFont, TRUE, , ahk_id %tooltipID%     ; set the font of the tooltip

    I wrote the following ahk code in order to examine the font of the tooltip after I send it the WM_SETFONT message:

      SendMessage, 0x31,,,, ahk_id %hwnd%                ; Get handle to tooltip's font

      hDC := DllCall("GetDC", "Uint", ahk_id %hwnd%)           ; Get device context (DC) handle
      DllCall("SelectObject","Uint",hDC,"Uint",hFont)          ; Select font to get information
      DllCall("GetTextMetrics", "Uint", hDC, "Uint", &lptm)    ; Get font data

      ul := NumGet(lptm, 49, "UChar")

     MsgBox %ul%

    The value for 'ul' is 0, which is what it should be according to how I create the logical font in ahk. However, as I described, the tooltip is acting as if the value of 'ul' is 255.

    Here is a screenshot illustrating the problem. The screenshot results from running an ahk script which does two things:

    1) creates a "Hello World" tooltip using the ahk 'Tooltip' command

    2) changes the font of all tooltips

    As the screenshot shows, the "Hello World" tooltip has the desired font, but the Windows Explorer tooltip has the font underlined.

    Any advice on how I can change a tooltip's font without it being underlined is much appreciated!

    Friday, July 20, 2012 2:53 PM