BUG: eVB: TreeView: Showing Form on NodeClick Event Displays It Behind Active Form (261940)



The information in this article applies to:

  • Microsoft eMbedded Visual Basic 3.0

This article was previously published under Q261940

SYMPTOMS

If you have a project that contains a TreeView control and you show a form in the NodeClick event of the TreeView control, the form that is shown appears behind the form that contains the TreeView control.

CAUSE

After the new form is loaded, the TreeView control fires its GotFocus event. This causes the form that contains the control to get the focus.

RESOLUTION

To work around this problem, set the Enabled property of the TreeView control to False in the NodeClick event before showing the other Form, and then reset the Enabled property to True in the Form_Activate event. Replace the code in the sample under "Steps to Reproduce Behavior" later in this article with the following:
Option Explicit

Private Sub Command1_Click()
    Form2.Show
End Sub

Private Sub Form_Activate()
    TreeViewCtl1.Enabled = True
End Sub

Private Sub Form_Load()
    TreeViewCtl1.Nodes.Add , , , "Node One"
    TreeViewCtl1.Nodes.Add , , , "Node Two"
End Sub

Private Sub TreeViewCtl1_NodeClick(ByVal Index As Long)
    TreeViewCtl1.Enabled = False
    Form2.Show
End Sub
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open Microsoft eMbedded Visual Basic 3.0.
  2. Create a new Windows CE HPC PRO project. Form1 is created by default.
  3. On the Project menu, click to select Add Form. Form2 is added by default.
  4. On the Project menu, click to select Components, and then click to add the Microsoft CE TreeView Control 3.0.
  5. Add a CommandButton and a TreeView control to Form1.
  6. Paste the following code into Form1:
    Option Explicit
    
    Private Sub Command1_Click()
        Form2.Show
    End Sub
    
    Private Sub Form_Load()
        TreeViewCtl1.Nodes.Add , , , "Node One"
        TreeViewCtl1.Nodes.Add , , , "Node Two"
    End Sub
    
    Private Sub TreeViewCtl1_NodeClick(ByVal Index As Long)
        Form2.Show
    End Sub
    					
  7. Run the project on the device or in emulation, and click on Command1. Form2 is displayed in front of Form1.
  8. Close Form2, click on Node One of the TreeView control on Form1, and note that Form2 is displayed behind Form1.

REFERENCES

262520 BUG: eVB: NodeClick Event Fires the First Time TreeView Control Gets Focus


Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbDSupport KB261940