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

Tagged as

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
            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)

Share

About the Author

MeritUSA

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 31 Aug 2010
Article Copyright 2010 by MeritUSA
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid