Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleChange a Frame control's background color
KeywordsFrame, control, BackColor, background, color
CategoriesControls, Graphics
 

Thanks to Rob Crombie.

Normally when you change a Frame control's BackColor property, the part of the control above the upper line sticks up and looks ugly. This routine covers that area with a Shape control that has the same color as the parent form, effectively hiding that area.

 
Public Sub HideTheUglyTopOfFrame(cFrame As Frame, cShape As _
    Shape, Optional FillColor As Long = -1)
    'Sorry, but I must set the frame's Font (as it affects
    ' the size of the area above the top border)
    cFrame.Font = "MS Sans Serif"
    cFrame.FontBold = False
    cFrame.FontSize = 8
    cFrame.Caption = ""   'Place your own descriptive Label
        ' within the Frame, instead.
    
    With cShape
        .BackStyle = 1   'Opaque
        .BorderStyle = 0 'Transparent
        .Height = 105
        .Left = 0
        .Top = 0
        .Width = cFrame.Width + 300  'To avoid slight lack
            ' of (right) coverage on larger frames.
        If FillColor = -1 Then
            .BackColor = cFrame.Parent.BackColor
        Else
            'Caller must have the frame in non Form
            ' container, and has passed me it's backcolor
            .BackColor = FillColor
        End If
    End With
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated