BUG: TreeView ToolTips Flash When Displayed From Modal FormID: Q189608
|
When the Microsoft TreeView control has been added to a Visual Basic form,
and the user hovers the mouse cursor over a node whose text is longer than
the control's width, a ToolTip should appear with that text. However, if
the form is being displayed modally, the ToolTips will "flash" on and off
repeatedly. This behavior occurs only in the compiled version of the
application and not in the Visual Basic design environment (IDE.)
This problem occurs under both Windows 95/98 and NT4 using Visual Basic
6.0, but is limited to the Windows 95/98 platform for Visual Basic 5.0.
Whenever possible, limit the use of the TreeView control to non-modal
forms. If you need to use the TreeView control in a modal dialog, you can
simulate modal behavior using a method such as the one documented below.
NOTE: The following method uses a Do-While loop with a single DoEvents
statement to force the program to continually poll and process messages
from the message queue while it waits for the dialog to be hidden. While
this technique will work in most cases, it is highly inefficient and has
been known to cause some problems with control event notification.
NOTE: Microsoft provides this workaround for illustration only, without
warranty either expressed or implied, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose.
To simulate invoking a Visual Basic Form modally, use the following call in
place of the normal Show method:
ShowModalForm Form2
Public Sub ShowModalForm(frmTarget As Form)
Dim ofrm As Object
' Disable all the forms
For Each ofrm In Forms
ofrm.Enabled = False
Next ofrm
' Now show the target form non-modal
frmTarget.Show
' If the frmTarget was disabled by the loop above
' make sure it is now enabled
frmTarget.Enabled = True
' Sit in a loop until the target form is dismissed
Do While frmTarget.Visible = True
DoEvents
Loop
' We have left the loop, so the dialog has been dismissed
' Now Enable the forms, and exit the procedure
For Each ofrm In Forms
If ofrm.Name = frmTarget.Name Then
Unload ofrm
Else
ofrm.Enabled = True
End If
Next ofrm
End Sub
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
Private Sub Form_Load()
With TreeView1
.Nodes.Add Key:="TEST1", _
Text:="Test1 : Does Long Node Text Name Flash?"
.Nodes.Add Key:="TEST2", _
Text:="Test2 : Does Long Node Text Name Flash?"
.Nodes.Add Key:="TEST3", _
Text:="Test3 : Does Long Node Text Name Flash?"
End With
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
Q173943 : BUG: TreeView ToolTips Do Not Appear on Windows NT
Additional query words: kbDSupport kbDSD kbVBp kbCtrl kbVBp500bug kbWinOS98 kbVBp600 kbWinOS95
Keywords :
Version :
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: June 16, 1999