1

We use classic native OS tooltips for clipped texts. However, if so-called large fonts are used in the OS

enter image description here

, our tooltip window appears as an empty window of a very small size (about 13x5 pixels). See it magnified below - it is near the cursor:

enter image description here

Is it a known bug? If so, how to solve this problem?


Below is the code of the method used to initialize a tooltip:

Public Function Create(ByVal ParentHwnd As Long) As Boolean
   Dim lWinStyle As Long

   If m_lTTHwnd <> 0 Then
      DestroyWindow m_lTTHwnd
   End If

   m_lParentHwnd = ParentHwnd

   lWinStyle = TTS_ALWAYSTIP Or TTS_NOPREFIX

   m_lTTHwnd = CreateWindowExA(0&, _
      TOOLTIPS_CLASS, _
      vbNullString, _
      lWinStyle, _
      CW_USEDEFAULT, _
      CW_USEDEFAULT, _
      CW_USEDEFAULT, _
      CW_USEDEFAULT, _
      0&, _
      0&, _
      App.hInstance, _
      0&)

   'now set our tooltip info structure
   Dim tiA As TOOLINFOA
   Dim tiW As TOOLINFOW
   If g_bIsNt Then
      With tiW
         .lSize = Len(tiW)
         .lFlags = TTF_SUBCLASS Or TTF_IDISHWND
         .hWnd = m_lParentHwnd
         .lId = m_lParentHwnd '0
         .hInstance = App.hInstance
         .lpStr = StrPtr(mvarTipText)
      End With
   Else
      With tiA
         .lSize = Len(tiA)
         .lFlags = TTF_SUBCLASS Or TTF_IDISHWND
         .hWnd = m_lParentHwnd
         .lId = m_lParentHwnd
         .hInstance = App.hInstance
         .lpStr = mvarTipText
      End With
   End If

   'add the tooltip structure
   If g_bIsNt Then
      SendMessage m_lTTHwnd, TTM_ADDTOOLW, 0&, tiW
   Else
      SendMessage m_lTTHwnd, TTM_ADDTOOLA, 0&, tiA
   End If

   'if we want a title or we want an icon
   If mvarTitle <> vbNullString Or mvarIcon <> igToolTipIconNone Then
      If g_bIsNt Then
         SendMessage m_lTTHwnd, TTM_SETTITLEW, mvarIcon, ByVal StrPtr(mvarTitle)
      Else
         SendMessage m_lTTHwnd, TTM_SETTITLEA, mvarIcon, ByVal mvarTitle
      End If
   End If

   ' set the time parameters
   SendMessageByLongA m_lTTHwnd, TTM_SETDELAYTIME, TTDT_AUTOPOP, mvarVisibleTime
   SendMessageByLongA m_lTTHwnd, TTM_SETDELAYTIME, TTDT_INITIAL, mvarDelayTime

   'according to MSDN, we should set TTM_SETMAXTIPWIDTH to a positive value
   'to enable multiline tooltips
   SendMessageByLongA m_lTTHwnd, TTM_SETMAXTIPWIDTH, 0, 2147483647
End Function
TecMan
  • 2,743
  • 2
  • 30
  • 64
  • 3
    Try changing your use of `TTM_SETMAXTIPWIDTH` to set the width to something sensible (e.g. 800). – Jonathan Potter Oct 23 '15 at 20:15
  • @JonathanPotter, I set it to 100000, and it helped to solve the problem in my test environment. Give us some time to test on customer's site. A more professional solution would be to determine the screen size of the monitor containing the mouse pointer (in the case of multi-monitor configuration), but I think 100000 pixels is enough for the nearest future. BTW, why don't publish your comment as an answer? – TecMan Oct 26 '15 at 10:03
  • Even 100000 wide is ridiculous. You're setting the maximum width of the tooltip. Windows won't support any more than 64k pixels across in total, and you'd need 12 of the highest resolution monitors available now to get that. And who wants to read a tooltip across 12 monitors? Still, whatever works for you. – Jonathan Potter Oct 26 '15 at 10:39

1 Answers1

0

Setting TTM_SETMAXTIPWIDTH to 100000 helped to solve the problem:

SendMessageByLongA m_lTTHwnd, TTM_SETMAXTIPWIDTH, 0, 100000

@JonathanPotter, thanks a million.

TecMan
  • 2,743
  • 2
  • 30
  • 64