Detecting if balloon tooltip is visible

828 views Asked by At

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
1

There are 1 answers

0
Mike Weir On

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.