Microsoft KB Archive/189608: Difference between revisions
m (Text replacement - "[[../vbwin/q" to "[[../") |
m (Text replacement - """ to """) |
||
Line 22: | Line 22: | ||
== SYMPTOMS == | == SYMPTOMS == | ||
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 | 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.)<br /> | ||
<br /> | <br /> | ||
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. | 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. | ||
Line 91: | Line 91: | ||
<ol> | <ol> | ||
<li>Create a new Standard EXE project. Form1 is created by default.</li> | <li>Create a new Standard EXE project. Form1 is created by default.</li> | ||
<li>From the Project menu, click Components, and check | <li>From the Project menu, click Components, and check "Microsoft Windows Common Controls."</li> | ||
<li>Add a CommandButton to Form1.</li> | <li>Add a CommandButton to Form1.</li> | ||
<li><p>Paste the following code into Form1's code window:</p> | <li><p>Paste the following code into Form1's code window:</p> | ||
Line 103: | Line 103: | ||
<pre> Private Sub Form_Load() | <pre> Private Sub Form_Load() | ||
With TreeView1 | With TreeView1 | ||
.Nodes.Add Key:= | .Nodes.Add Key:="TEST1", _ | ||
Text:= | Text:="Test1 : Does Long Node Text Name Flash?" | ||
.Nodes.Add Key:= | .Nodes.Add Key:="TEST2", _ | ||
Text:= | Text:="Test2 : Does Long Node Text Name Flash?" | ||
.Nodes.Add Key:= | .Nodes.Add Key:="TEST3", _ | ||
Text:= | Text:="Test3 : Does Long Node Text Name Flash?" | ||
End With | End With | ||
End Sub | End Sub |
Latest revision as of 12:41, 21 July 2020
BUG: TreeView ToolTips Flash When Displayed From Modal FormID: Q189608 |
The information in this article applies to:
- Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
SYMPTOMS
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.
RESOLUTION
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
The code for ShowModalForm is shown below, and can be placed in a Form or standard code module:
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
STATUS
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.
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new Standard EXE project. Form1 is created by default.
- From the Project menu, click Components, and check "Microsoft Windows Common Controls."
- Add a CommandButton to Form1.
Paste the following code into Form1's code window:
Private Sub Command1_Click() Form2.Show vbModal End Sub
- From the Project menu, click Add Form and add a new form, Form2, to the project.
- Place a TreeView control on Form2. Size it to be about 1/2 inch wide.
Paste the following code into Form2's code window:
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
- Choose Make exe from the File menu to compile the project to an EXE.
- Run the compiled program and click on Command1. Note that as you hover the mouse over the nodes of the TreeView, the ToolTip that appears will flash.
REFERENCES
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