PRB: Focus on the Tab Control Changes to an Inactive Tab

Last reviewed: December 23, 1997
Article ID: Q178469
The information in this article applies to:
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0

SYMPTOMS

With the Microsoft Tabbed Dialog (tabctl32.ocx), focus may shift to a control on an inactive tab.

CAUSE

This problem may occur with the tabbed dialog when one of the tabs has a container control, such as a frame or picture control.

RESOLUTION

To work around this problem, disable the controls on inactive tabs so that they will not be in the tab order. You can disable the controls in the Click event of the tab control. For example:

   Private Sub SSTab1_Click(PreviousTab As Integer)
      Dim c As Control
      For Each c In Controls
         If (c.Container Is SSTab1) Then
            c.Enabled = (c.Left >= 0)
         End If
      Next
   End Sub

NOTE: When a control contained in an SSTab control is on an inactive tab, the Left property of the control is negative.

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Standard EXE project in Visual Basic. Form1 is created by default.

  2. Add a reference to the Microsoft Tabbed Dialog Control 5.0 by completing the following steps:

    a. From the Project menu, click Components.

    b. From the Controls list, check Microsoft Tabbed Dialog Control 5.0.

    c. Click OK to close the Components dialog box.

  3. Add a Tab control to Form1 and set the Tabs property of the Tab control to 2.

  4. On the first tab of the Tab control, add a text box. On the second Tab, add a frame control. In the frame control, add a text box.

  5. Copy the following code to the Code window of the Form1 form:

          Option Explicit
          Private Sub Text1_GotFocus()
    
             Debug.Print "Text1 GotFocus"
          End Sub
    
          Private Sub Text2_GotFocus()
             Debug.Print "Text2 GotFocus"
          End Sub
    
    

  6. On the Run menu, click Start or press the F5 key to start the program. Set the focus to the text box of the first tab. Press the TAB key to change the focus. Examine the messages in the Immediate pane. Note that the focus moves to the text box in the second tab, which is not displayed and therefore inactive.


Additional query words: tabctl32.ocx tab dialog tabstrip tab strip sstab
sheridan
Keywords : vb5all
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type : kbprb


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.

Last reviewed: December 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.