TABSTRIP

USUARIO.EXCLUIDOS 03/04/2005 22:53:15
#76455
Boa noite pessoal,
Estou usando um tabstrip com 3 tabs, em cada tabs existe uma TextBox, na primeira tabs e na segunda estou usando o evento KeyPress, pois bem, eu gostaria que quando eu der um enter na primeira TextBox da primeira tabs o foco ia para a segunda TextBox da segunda tabs e quando der outro enter o foco ia para a terceira TextBox da terceira tabs.

Obrigado
USUARIO.EXCLUIDOS 04/04/2005 09:02:37
#76479
Coloque num módulo:

Public Function CheckForMouse(ByRef TBox As TextBox) As Boolean
'Routine to determine if a mouse click
'was used to set focus to a control.
'If not a mouse then select the contents
'of the control (Like most other apps)
'Even though I'm using 'As TextBox' here,
'this routine will work with any control that
'exposes SelStart, SelLength and Text properties.
Const VK_LBUTTON = &H1
Dim btArray(255) As Byte

Call GetKeyboardState(btArray(0))

If ((btArray(VK_LBUTTON) And &H80) <> &H80) Then
With TBox
If .SelLength = 0 Then
.SelStart = 0
.SelLength = Len(.Text)
End If
End With
Else
CheckForMouse = True
End If
End Function

Private Sub FindCorrectControl(TabNumber As Integer)
'Find the control with the lowest TabIndex
'on the current tab. Controls must be contained
'by an element of the fraTab control array.
Dim c As Control
Dim cFocus As Control
Dim i As Integer

i = 10000 'Out of range to start
For Each c In Controls
If c.Container Is fraTab(TabNumber) Then
If c.TabIndex < i Then
i = c.TabIndex
Set cFocus = c
End If
End If
Next c

On Error Resume Next
cFocus.SetFocus

End Sub

Private Sub CheckForSwitch(ByRef TBox As TextBox)
If Check1.Value = vbChecked Then
'First make sure a mouse wasn't used.
'If the user clicks on a certain box, we wouldn't
'want to change tabs.. but if it was the keyboard,
'go ahead and change tabs.
If Not CheckForMouse(TBox) Then
If SSTab1.Tab + 1 < SSTab1.Tabs Then
SSTab1.Tab = SSTab1.Tab + 1
Else
SSTab1.Tab = 0
End If
End If
End If
End Sub

Private Sub ChangeTabs()
Dim iTabs As Integer
For iTabs = 0 To SSTab1.Tabs - 1
'Visible only if on the current tab.
fraTab(iTabs).Enabled = (SSTab1.Tab = iTabs)
Next iTabs
Call FindCorrectControl(SSTab1.Tab)
End Sub


E isto em cada textbox final da tabstrip:

Private Sub Text1_GotFocus()
Call CheckForMouse(Text1)
End Sub
USUARIO.EXCLUIDOS 04/04/2005 09:14:14
#76483
http://www.vbmania.com.br/vbmdetail.php?varID=2613

Poxa... Foi mal... Agora que eu vi que vc usa tabstrip!!!

Minha sugestão é usar a SSTAB... Disponível em:

C:\Windows\System\TABCTL32.OCX
Tópico encerrado , respostas não são mais permitidas