Click to See Complete Forum and Search --> : Problem on SSTab using TAB key to move focus between controls


MarkRM
March 1st, 2000, 12:35 PM
I've written an application using the SSTab control, with 8 tabs and 259 controls, 136 of which have .TabStop=False and some are .Visible=False

When I use the TAB key to move from one control to the next, I expect it to cycle round between the tab control itself and each control of the selected tab.

However on mine, the TAB key goes round the visible tab controls on the current tab and then focus disappears for 35 TAB presses before returning focus to the visible controls!

I tried this morning to build a simple example with 3 tab and 3 controls on each and it worked perfectly, cycling through only Tab0, Command1, Command2 and Text1, then back to Tab0.

When I do this on the first tab, though, the focus only disappears for one TAB press, but on each other the it is gone for 35.

Other factors which may throw light on this:
1) There are 35 active controls on my first tab, including the SSTab itself.
2) I know that the 35 hidden TAB presses are stepping through the controls on the first tab.
3) I do not know where the focus goes during the one hidden TAB press from the first tab.

Anybody seen this before? Any suggestions or known fixes?

Regards


Mark

AndyK
March 1st, 2000, 02:24 PM
I think each control has tab index property, maybe you should kind of skip those 35 "hidden" controls, and just set next tab index to whatever you need to, so say for example your text1 has tabindex 1, text2 has tabindex 2, text3 has tabindex 3 but the text3 is hidden, text4 has tabindex 4, so why not make text4 with tabindex 3, so it'll skip text3 which is hidden

Kyle Burns
March 1st, 2000, 02:49 PM
Since you're going to toggle the visiblity of these controls anyway, it wouldn't be that much work to also toggle the tabstop. You could place the toggle in a seperate procedure.

Sub ToggleControl(ctl as Control, State as Boolean)
on error resume next
'Don't let sending a control that
'doesn't have a tabstop or visible
'property hose you
ctl.Visible = State
ctl.TabStop = State
End Sub

MarkRM
March 2nd, 2000, 05:42 AM
Thanks Andy & Kyle. Unfortunately these suggestions do not help. I believe I am suffering from a bug in the SSTab control. To descibe the problem in further detail...

I am not changing the visibility of controls using my code, it is the SSTab control which shows the selection of controls which were placed on each tab at design time. When I change tabs, the SSTab control deals with which controls to display.

I only change the .Visible property of a few controls, depending on the selections in combo boxes, etc. Those controls which have .Visible=False or .Enabled=False are not given focus at any time, as you would expect.

Changing tab order does not help. Even labels have .TabIndex property, but they never get focus. When I refer to 'focus disappears' or hidden, I mean that no control on the current tab has focus.

I also have evidence from presssing Return every now and then which proves which hidden control does have focus, as each button causes specific data to be sent to the serial port.

Regards

Mark

TH1
March 2nd, 2000, 08:22 AM
I had the same problem.What I did is similar to what I did was in the form load I disabled the tabstop on every control expect for the SSTab itself and all the controls on the first tab.

private Sub DisableTabstop(frm as Form)
on error resume next
Dim ctl as Control
for Each ctl In frm.Controls
If TypeOf ctl is Label then
'Ignore
else
ctl.TabStop = false
End If
next
End Sub



Then in the click_event of the tab control.I again disable all controls except for the SStab and the controls on the tab that is now being shown. This you can check with a simple case statement

select case SSTAB1.tab
Case 0
Case 1
'Etc
end select



I know that this sounds very long winded but it was the only way that I could get round the problem.
Hope this helps
Tony

MarkRM
March 2nd, 2000, 09:42 AM
Thanks Tony, I'll give it a try.

I have discovered that the problem is related to the use of frames. I had lots of controls inside frames to allow background colour to show groups of controls. It seems that the SSTab control does not prevent focus going to all the controls within each frame.

I have now taken almost all controls out of the frames and used ZOrder to make them sit on top of the frames. This has reduced the number of hidden TAB presses from 35 to 4. This is how many frames I still have containing radio buttons which have to be grouped in frames to allow one of each group to be selected.

An example which demonstrates the problem easily is described below. I can't post it here because it includes a binary .frx file for the SSTab control.

1) Create a new form
2) Add an SSTab control (First add the "Microsoft Tabbed Dialog Control 6.0 (SP3)" component)
3) Add a frame on Tab0
4) Ensure the frame is selected and add a Command button into the frame
5) Add another button onto Tab0
6) Add another button on Tab1
7) Paste in the code below

private Sub Command1_Click()
MsgBox "Command1 on Frame1"
End Sub

private Sub Command2_Click()
MsgBox "Command2"
End Sub

private Sub Command3_Click()
MsgBox "Command3"
End Sub




8) Run the code and select Tab0.
9) Press TAB several times and observe the focus move through Command1, Command2, Tab0 and back to Command1.
10) Select Tab1. Press TAB several times and observe that focus disappears for one TAB press. When this happens, press Enter and see the message box tell you that the button you pressed was the one in Frame1!


A further bug exists in the SSTab control, in that you can only specify one Command button to have the .Default=True property. I would expect to be allow one on each tab. I have had to perform the default button selection in the SSTab1_Click() routine.


Mark

TH1
March 2nd, 2000, 10:22 AM
Mark, I tried your example and used my method and it works so do the following.
Keep your code as is and paste the following into your form
private Sub Disable()
Dim ctl as Control
for Each ctl In Controls
If TypeOf ctl is Frame Or TypeOf ctl is SSTab then
'Ignore
else
ctl.TabStop = false
End If
next
End Sub



then in the form load paste the following

Disable
Command1.TabStop = true
Command2.TabStop = true



then in the click event of the SStab paste the following.

Disable
Select Case SSTab1.Tab
Case 0
Command1.TabStop = true
Command2.TabStop = true
Case 1
Command3.TabStop = true
End Select




Crap way of doing it but it works
Cheers
Tony.

MarkRM
March 2nd, 2000, 10:45 AM
Thanks again, Tony.

Even simpler, I've pasted the following into the SSTab Click routine. It is unnecessary to fiddle with any control other than the frames themselves, because disabling the frame automatically disables all its contents. This avoids the need to iterate through all the controls within each frame and it works perfectly.

I could have iterated through 'Each ctl In Controls' to disable the frames instead of my explicit code, but my method is probably slightly quicker.

[/vbcode]
Private Sub tabPteZ_Click(PreviousTab As Integer)
' SSTab bug workaround - disable frames except on the current tab, otherwise TAB key still selects controls inside them
If (tabPteZ.Tab = TAB_MAIN) Then
fraDvr.Enabled = True
fraPte.Enabled = True
fraStvQuadZ(0).Enabled = True
fraStvQuadZ(1).Enabled = True
fraStvQuadZ(2).Enabled = True
Else
fraDvr.Enabled = False
fraPte.Enabled = False
fraStvQuadZ(0).Enabled = False
fraStvQuadZ(1).Enabled = False
fraStvQuadZ(2).Enabled = False
End If
' More code...
End Sub
[/vbcode]



Mark

Ravi Kiran
March 4th, 2000, 03:22 AM
Good discussion.

Each pane in SSTab itself is a Container. SO it must have been conflicting with the container properties of Frame Control.
If you are using Frame controls just for coloring the groups then you may be better off with Shape controls. They take less resources than a Frame!

RK

MarkRM
March 6th, 2000, 05:52 AM
I'm all for keeping code/memory requirements small where possible!

Regards

Mark