Click here to Skip to main content
12,887,779 members (47,269 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 27 Aug 2010

Set the BackColor to SSTab in VB6 (workaround)

, 31 Aug 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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
                '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


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


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 31 Aug 2010
Article Copyright 2010 by MeritUSA
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid