Click here to Skip to main content
Click here to Skip to main content

Set the BackColor to SSTab in VB6 (workaround)

By , 31 Aug 2010
 
I couldn't really find any solution to this, but after this workaround did what I needed I figured I could share it. The actual tabs will not change color with this workaround, but I can live with that.
 
I only tested this with SSTab having orientation = top .
 
Private Sub SetSSTabBackColor(SSTbCntrl As SSTab, lColor As Long)
Dim ctl As Control
Dim CtlTop As Long, CtlLeft As Long, CtlWidth As Long, CtlHeight As Long
Dim i As Integer, CtlFound As Boolean
Dim SSTabMargin As Integer
    
    SSTbCntrl.Visible = False
    SSTabMargin = 40
    CtlTop = SSTbCntrl.TabHeight + SSTabMargin
    CtlLeft = SSTabMargin
    CtlWidth = SSTbCntrl.Width - (SSTabMargin * 2) + 10
    CtlHeight = SSTbCntrl.Height - SSTbCntrl.TabHeight - (SSTabMargin * 2) + 10
    
    ' Loop through tabs
    For i = 0 To SSTbCntrl.Tabs - 1
        CtlFound = False
        For Each ctl In Controls
            If ctl.Name = "SSBCCntrl" & i Then
                CtlFound = True
            End If
 
        Next ctl
        If CtlFound Then
                'control exists - don't create, just modify
                Controls("SSBCCntrl" & i).Move CtlLeft, CtlTop, CtlWidth, CtlHeight
                Controls("SSBCCntrl" & i).Caption = ""
                Controls("SSBCCntrl" & i).BackColor = lColor
            Else
                'control does not exist - create
                Set ctl = Controls.Add("vb.label", "SSBCCntrl" & i, Me)
                SSTbCntrl.Tab = i
                Set ctl.Container = SSTbCntrl
                ctl.Visible = True
                ctl.Move CtlLeft, CtlTop, CtlWidth, CtlHeight
                ctl.Caption = ""
                ctl.BackColor = lColor
        End If
        
    Next i
    SSTbCntrl.Tab = 0
    SSTbCntrl.Visible = True
End Sub
 
You can access the subroutine from the activate or resize event (not load)
Private Sub Form_Activate()
    SetSSTabBackColor SSTab1, vbRed
End Sub

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

MeritUSA
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 31 Aug 2010
Article Copyright 2010 by MeritUSA
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid