Article ID: 167107
Article Last Modified on 6/24/2004
APPLIES TO
- Microsoft Visual Basic 5.0 Control Creation Edition
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q167107
SYMPTOMS
One or more of the tabs on the SSTAB control is missing its controls when displayed at run-time.
CAUSE
The SSTab control does not respond correctly when attempting to manipulate the Tab or TabVisible properties from the Form-Load event. If the SSTab control has not completely finished initializing when you attempt to set the Tab property to reflect a value different than the default, then the controls are still located in their temporary holding area at -72960. The Tab will display without its controls. To guarantee that the SSTab control has finished initializing, you can access its properties from any event after Form_Load has completed and the SSTab can receive the focus. This will occasionally work from the Form_Load event but has inconsistent behavior when you have various controls on one the tabs.
RESOLUTION
Tab Property
If you attempt to set a certain tab as the current tab on initial display, then setting the Tab property in either the Form_Activate event or the SSTab1.Got_Focus event instead of the Form_Load event fixes this problem, as follows:
Private Sub Form_Activate Static bReactivate as Boolean 'default is false If Not bReactivate Then SSTab1.Tab = GetSetting("MyApp","Settings","MyTab",0) bReactivate = True End If End Sub
TabVisible Property
If you attempt to display only a certain tab on initial display, then setting the desired tab as the current tab and then setting the REMAINING tabs TabVisible property to false in reverse order (leaving the current tab set to visible) from either the Form_Activate event or the SSTab.Got_Focus events solves this problem, as follows:
Private Sub Form_Activate() Static bReactivate as Boolean 'default is false If Not bReactivate Then SSTab1.Tab = GetSetting("MyApp","Settings","MyTab",0) For i = SSTab1.Tabs - 1 To 0 Step -1 If SSTab1.Tab <> i Then SSTab1.TabVisible(i) = False End If Next i bReactivate = True End If End Sub
This code assumes that have stored an entry "MyTab" in the registry.
The GetSetting function can be replaced with a module level Public integer variable and set as needed.
- You should not make the current tab invisible using SSTab1.TabVisible() = False.
- You should not set an invisible tab as the current tab.
- You should always leave at least one 'tab' set to visible. If you want to make all the tabs invisible, use SSTab1.Visible = False
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Studio 97 Service Pack 2.
For more information on the Visual Studio 97 Service Pack 2, please see the following article in the Microsoft Knowledge Base:
170365 : INFO: Visual Studio 97 Service Packs - What, Where, and Why
For a list of the Visual Basic 5.0 bugs that were fixed in the Visual Studio 97 Service Pack 2, please see the following article in the Microsoft Knowledge Base:
171554 : INFO: Visual Basic 5.0 Fixes in Visual Studio 97 Service Pack 2
MORE INFORMATION
Activate & Got_Focus
If you do not want the tab selected every time the SSTab control or the form its on receives focus, then use a Static flag such as bReactivate in the sample. If you do want the tab to be set every time the form receives focus, then remove the flag:
Private Sub Form_Activate SSTab1.Tab = GetSetting("MyApp","Settings","MyTab",0) End Sub
Steps to Reproduce Behavior
SSTab Control
Tab property:
- Put an SSTab control with five tabs on a form.
- Add a textbox to each tab.
- Click on tab 0 to set design time current tab to 0.
In Form_Load, add:
SSTab1.Tab = 3
- Run the project and note that the textbox will be gone. The textbox is actually at -72960.
Tabvisible property:
- Put an SSTab control with three tabs on a form.
- Add a textbox to each tab.
In form load, add:
sstab1.tabvisible(0) = false sstab1.tabvisible(1) = false sstab1.tabvisible(2) = false *(this will fail with the older SSTab, giving invalid property value)
Put three CommandButtons on the form, reversing what was done in form load:
sstab1.tabvisible(0) = true sstab1.tabvisible(1) = true sstab1.tabvisible(2) = true
Note that the textbox will be gone; it is actually at -72960.
REFERENCES
For more information, please see the following article in the Microsoft Knowledge Base:
149328 : Selecting Invisible Tab Can Cause GPF with SSTab Control
Additional query words: missing invisible kbVBp500fix kbVBp kbWinOS98 kbDSupport kbdse kbVBp400fix
Keywords: kbbug kbfix KB167107