SetColorBar
' Creates a color bar background for a ListView when in ' report mode. Passing the listview and picturebox allows ' you to use this with more than one control. You can also ' change the colors used for each by passing new RGB color ' values in the optional color parameters.
AI
AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
소스 코드
Public Sub SetColorBar(cListView As ListView, cColorBar As PictureBox, Optional lColor1 As Long = &HE2F1E3, Optional lColor2 As Long = vbWhite)
' Creates a color bar background for a ListView when in
' report mode. Passing the listview and picturebox allows
' you to use this with more than one control. You can also
' change the colors used for each by passing new RGB color
' values in the optional color parameters.
Dim iLineHeight As Long
Dim iBarHeight As Long
Dim lBarWidth As Long
On Error GoTo SetColorBarError
' set picture to none and exit sub if not in report mode
If Not cListView.View = lvwReport Then GoTo SetColorBarError
' these can be commented out if the cColorBar control
' is set correctly.
cColorBar.AutoRedraw = True
cColorBar.BorderStyle = vbBSNone
cColorBar.ScaleMode = vbTwips
cColorBar.Visible = False
' set the alignment to "Tile" and you only need
' two bars of color.
cListView.PictureAlignment = lvwTile
' needed because ListView does not have "TextHeight"
cColorBar.Font = cListView.Font
' set height to a single line of text plus a
' one pixel spacer.
iLineHeight = cColorBar.TextHeight("|") + Screen.TwipsPerPixelY
' set color bars to 3-line wide.
iBarHeight = iLineHeight * 3
lBarWidth = cListView.Width
' resize the cColorBar picturebox
cColorBar.Height = iBarHeight * 2
cColorBar.Width = lBarWidth
' paint the two bars of color
cColorBar.Line (0, 0)-(lBarWidth, iBarHeight), lColor1, BF
cColorBar.Line (0, iBarHeight)-(lBarWidth, iBarHeight * 2), lColor2, BF
' set the cListView picture to the
' cColorBar image
cListView.Picture = cColorBar.Image
Exit Sub
SetColorBarError:
' clear cListView's picture and then exit
cListView.Picture = LoadPicture("")
End Sub
원본 댓글 (3)
Wayback Machine에서 복구됨