1

My program makes heavy use of the Windows build-in balloon tooltips, but on some system they are just not displayed. This can have so many different causes (for example: EnableBalloonTips, ShowInfoTip, DisablePreviewDesktop, TaskbarNoNotification are all different registry keys that can have influence), that its almost imposible to correct those settings during installation.

So my alternative was to simply test if the balloon is visible, and if not, display a message they should contact support. However all methods I use on the hWnd of the tooltip (IsWindowVisible, GetActiveWindow, etc) all return that the balloon is visible, even in cases when its not. I suspect this has something to do with Windows assigning the parent's hWnd to the balloon, so how can I check its actually displayed correctly?

Public Sub Create(ByVal hWndParent As Long, _
  Optional ByVal bAlwaysTip As Boolean = True, _
  Optional ByVal bBalloonTip As Boolean = True)

  Dim nFlags As Long

  ' Wir möchten kein normales Fenster :-)
  nFlags = WS_POPUP Or TTS_NOPREFIX

  ' Falls der ToolTip auch bei deaktiviertem 
  ' Control erscheinen soll...
  If bAlwaysTip Then nFlags = nFlags Or TTS_ALWAYSTIP

  ' Falls ein "moderner" Balloon-ToolTip erwünscht...
  If bBalloonTip Then nFlags = nFlags Or TTS_BALLOON

  ' Window-Handle erstellen  
  m_hWnd = CreateWindowEx(0, "tooltips_class32", 0, _
    nFlags, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
    CW_USEDEFAULT, hWndParent, 0, App.hInstance, 0)

  ' maximale Fensterbreite festlegen
  SendMessageLong m_hWnd, TTM_SETMAXTIPWIDTH, 0, m_lMaxWidth
End Sub

Public Sub SetToolTipText(hWnd As Long, ByVal strText As String)

    Dim udtToolInfo As TOOLINFO
    With udtToolInfo
        .hWnd = hWnd
        .uId = hWnd
        .lpszText = strText
        .cbSize = Len(udtToolInfo)
    End With

    SendMessage m_hWnd, TTM_UPDATETIPTEXTA, 0, udtToolInfo

End Sub
Maestro
  • 9,046
  • 15
  • 83
  • 116
  • 2
    Can you show some of the code you are using to create the tooltip? Perhaps the creation calls or displaying calls would produce an error that you are not paying attention to, that could be of use. – Mike Weir Aug 20 '13 at 13:40
  • @PhoenixX_2 Only a very small percentage of our users have this problem, and changing registry settings fixes the issue in most cases, so I think that rules out any errors in the code. – Maestro Aug 21 '13 at 18:32
  • I didn't mean to say that you'd have errors. I meant that return values of certain functions might indicate that their settings do not indeed allow for balloons to pop-up. – Mike Weir Aug 21 '13 at 18:56
  • @PhoenixX_2 Ah, I misread it. The balloon is created using the default CreateWindow API call, which doesnt seem to return an error on systems where balloons are disabled, and all further communication (setting the text, show/hide ballon) are through the SendMessage API call, which never returns a value because the message are passed asynchronously, so the call returns before the outcome is known. – Maestro Aug 21 '13 at 21:49

1 Answers1

0

You should indeed isolate the registry keys that affect your application and make the appropriate changes. If that's what you end up doing through support, maybe it's natural to just make the changes forcibly.

But what would be an even better idea is to write your own solution, as in, create your own window that is directly tailored to your application. It would give you the power you'd want without Windows tackling you all the time.

Mike Weir
  • 3,094
  • 1
  • 30
  • 46