Re: Change Box Color on CheckBox Control
- From: schaefty@xxxxxxxxxxx
- Date: 18 Aug 2006 13:10:34 -0700
Then for all practical purposes, you don't need the checkbox functionality
for those mirrored checkboxes, do you? You could just show an image
of a checked box. (That's one way). If that is close to what you need,
you might also just draw the checkboxes on the form as needed. Because
they are not any sort of control, clicking on them has no effect....
For an example, add a Module to a new project and put a checkbox on
the default form. Set the checkbox's Index property to 0 and paste in the
code below to their respective modules. The grey boxes will mirror the
real ones....
HTH
LFS
' [ Form1 code ]
Option Explicit
Private Sub Check1_Click(Index As Integer)
DrawCheckbox Me.hDC, 10, Check1(Index).Top, (Check1(Index).Value = vbChecked)
End Sub
Private Sub Form_Load()
Dim idx As Long
Show
Refresh
ScaleMode = vbPixels
For idx = 0 To 5
If idx Then Load Check1(idx)
Check1(idx).Caption = "ITEM " & idx
Check1(idx).Move 40, idx * 18 + 10
Check1(idx).Visible = True
DrawCheckbox Me.hDC, 10, Check1(idx).Top, False
Next
End Sub
' [ Module1 code ]
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawFrameControl Lib "user32" ( _
ByVal hDC As Long, _
lpRect As RECT, _
ByVal un1 As Long, _
ByVal un2 As Long) As Long
Private Const DFC_BUTTON As Long = 4
Private Const DFCS_CHECKED As Long = &H400
Private Const DFCS_INACTIVE As Long = &H100
Public Sub DrawCheckbox(ByVal hDC As Long, _
ByVal Left As Long, ByVal Top As Long, _
ByVal Checked As Boolean)
Dim rct As RECT
rct.Left = Left
rct.Top = Top
rct.Right = rct.Left + 30
rct.Bottom = rct.Top + 13
DrawFrameControl hDC, rct, DFC_BUTTON, DFCS_INACTIVE Or (Checked And DFCS_CHECKED)
End Sub
Well, at least I have learned that it is not as trivial as I first
expected it to be. Thanks for everyone's help. I think the idea of
just putting up the image of a checked gray box or an unchecked gray
box might be a good road. I did try to copy and paste in this code,
but all sorts of errors. I am working with VS2005...was this code for
another version?
I agree that changing the color of the text would also work (and be
easy to implement) but it isn't really the look I want.
.
- Follow-Ups:
- Re: Change Box Color on CheckBox Control
- From: Jeff Johnson
- Re: Change Box Color on CheckBox Control
- From: Ken Halter
- Re: Change Box Color on CheckBox Control
- References:
- Change Box Color on CheckBox Control
- From: schaefty
- Re: Change Box Color on CheckBox Control
- From: Jan Hyde
- Re: Change Box Color on CheckBox Control
- From: schaefty
- Re: Change Box Color on CheckBox Control
- From: Larry Serflaten
- Change Box Color on CheckBox Control
- Prev by Date: Re: Resize form problem
- Next by Date: Re: Resize form problem
- Previous by thread: Re: Change Box Color on CheckBox Control
- Next by thread: Re: Change Box Color on CheckBox Control
- Index(es):
Relevant Pages
|