DOCUMENT:Q189608 17-JUL-1998 [vbwin] TITLE :BUG: TreeView ToolTips Flash When Displayed From Modal Form PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0 OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.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.) Currently, this problem is limited to the Windows 95 and Windows 98 platforms. 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 --------------------------- 1. Create a new Standard EXE project. Form1 is created by default. 2. From the Project menu, click Components, and check "Microsoft Windows Common Controls." 3. Add a CommandButton to Form1. 4. Paste the following code into Form1's code window: Private Sub Command1_Click() Form2.Show vbModal End Sub 5. From the Project menu, click Add Form and add a new form, Form2, to the project. 6. Place a TreeView control on Form2. Size it to be about 1/2 inch wide. 7. 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 8. Choose Make exe from the File menu to compile the project to an EXE. 9. 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: ARTICLE-ID: Q173943 TITLE : BUG: TreeView ToolTips Do Not Appear on Windows NT Additional query words: kbDSupport kbDSD kbVBp kbCtrl kbVBp500bug kbWinOS98 kbWinOS95 ====================================================================== Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbbug Solution Type : kbpending ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1998.