Home All Groups Group Topic Archive Search About

Change box color on checkbox control

Author
21 Aug 2006 5:50 PM
schaefty
I recently posted this on the incorrect forum, and so I would like to
ask the question here.  I did get some good ideas on the other group,
but I have not yet come up with a solution for me.  I am using VS2005
(express edition) and coding in vb.net.

I wrote an application that uses 30 checkboxes to set the configuration
of a device.  The device is constantly polled, and its response is
decoded and reported in a mirror battery of another set of 30
checkboxes.  Therefore, the app is broken down into 1 grouping of
checkboxes that represent your desired state, and another grouping of
checkboxes that reports current actual state (these may differ for
various reasons).   I used the checkboxes such that if the box is
checked it represents a true for that state.

It all worked just fine, but the customer freaked out because they kept
wanting to access and click the "current state" group of checkboxes, or
they would simply look at the incorrect group, no matter how I
seperated them into groups on different parts of the app.  What they
demanded is to leave the functionality of the checkboxes as is, but to
simply gray the boxes on the "current states" to make them easier to
distinguish.

Therefore, all I want to do is take the little white box on the
checkbox control, and make it slightly gray.  I do not want to adjust
the functionality at all.  I assume I will have to make a new control
class and inherit the controlbox control and make the modifications
there.  I haven't been able to work this out yet.  Other options would
be to make a couple of images, one of a grayed box and the other with a
grayed box with a check, and just swap the images as necessary.  This
seems more complicated than it should be.

Thanks for any help!

-Rdog

Author
21 Aug 2006 11:21 PM
GhostInAK
Hello schae***@hotmail.com,

Check out CheckBox.Enabled

-Boo

Show quoteHide quote
> I recently posted this on the incorrect forum, and so I would like to
> ask the question here.  I did get some good ideas on the other group,
> but I have not yet come up with a solution for me.  I am using VS2005
> (express edition) and coding in vb.net.
>
> I wrote an application that uses 30 checkboxes to set the
> configuration of a device.  The device is constantly polled, and its
> response is decoded and reported in a mirror battery of another set of
> 30 checkboxes.  Therefore, the app is broken down into 1 grouping of
> checkboxes that represent your desired state, and another grouping of
> checkboxes that reports current actual state (these may differ for
> various reasons).   I used the checkboxes such that if the box is
> checked it represents a true for that state.
>
> It all worked just fine, but the customer freaked out because they
> kept wanting to access and click the "current state" group of
> checkboxes, or they would simply look at the incorrect group, no
> matter how I seperated them into groups on different parts of the app.
> What they demanded is to leave the functionality of the checkboxes as
> is, but to simply gray the boxes on the "current states" to make them
> easier to distinguish.
>
> Therefore, all I want to do is take the little white box on the
> checkbox control, and make it slightly gray.  I do not want to adjust
> the functionality at all.  I assume I will have to make a new control
> class and inherit the controlbox control and make the modifications
> there.  I haven't been able to work this out yet.  Other options would
> be to make a couple of images, one of a grayed box and the other with
> a grayed box with a check, and just swap the images as necessary.
> This seems more complicated than it should be.
>
> Thanks for any help!
>
> -Rdog
>
Author
21 Aug 2006 11:40 PM
RaoulDuke
GhostInAK wrote:
> Hello schae***@hotmail.com,
>
> Check out CheckBox.Enabled
>
> -Boo
>
>

While that is the look of the box that I want, I still need the text
and the check to be in black.  I believe I can still alter the
Checkbox.checked state even if it was disabled, so if you can tell me
how to get the text / check to black?
Author
22 Aug 2006 1:05 AM
GhostInAK
Hello RaoulDuke,

Override the control's paint procedure.

It may be best to just make a new control.

-Boo

Show quoteHide quote
> GhostInAK wrote:
>
>> Hello schae***@hotmail.com,
>>
>> Check out CheckBox.Enabled
>>
>> -Boo
>>
> While that is the look of the box that I want, I still need the text
> and the check to be in black.  I believe I can still alter the
> Checkbox.checked state even if it was disabled, so if you can tell me
> how to get the text / check to black?
>
Author
22 Aug 2006 8:06 PM
RaoulDuke
Yea, I think that I will have to make a new control class and start by
inheriting the standard checkbox control.  However, I don't know how to
override the paint procedure...


GhostInAK wrote:
Show quoteHide quote
> Hello RaoulDuke,
>
> Override the control's paint procedure.
>
> It may be best to just make a new control.
>
> -Boo
>
> > GhostInAK wrote:
> >
> >> Hello schae***@hotmail.com,
> >>
> >> Check out CheckBox.Enabled
> >>
> >> -Boo
> >>
> > While that is the look of the box that I want, I still need the text
> > and the check to be in black.  I believe I can still alter the
> > Checkbox.checked state even if it was disabled, so if you can tell me
> > how to get the text / check to black?
> >
Author
24 Aug 2006 5:57 PM
RaoulDuke
*bounce*    Still hoping for some help on this.  It seems it is much
harder than it should be.  Searching this forum, I see other people
have had the same question in the past, but I haven't really found a
suitable answer.

The one way that almost works is to remove the text associated with the
checkbox and put a label there instead.  Then you can set the enabled
property to false which gives the gray look nicely.  The only trouble
is the checkmark also becomes grayed out and too difficult to see
properly.

Thoughts?


RaoulDuke wrote:
Show quoteHide quote
> Yea, I think that I will have to make a new control class and start by
> inheriting the standard checkbox control.  However, I don't know how to
> override the paint procedure...
>
>
> GhostInAK wrote:
> > Hello RaoulDuke,
> >
> > Override the control's paint procedure.
> >
> > It may be best to just make a new control.
> >
> > -Boo
> >
> > > GhostInAK wrote:
> > >
> > >> Hello schae***@hotmail.com,
> > >>
> > >> Check out CheckBox.Enabled
> > >>
> > >> -Boo
> > >>
> > > While that is the look of the box that I want, I still need the text
> > > and the check to be in black.  I believe I can still alter the
> > > Checkbox.checked state even if it was disabled, so if you can tell me
> > > how to get the text / check to black?
> > >
Author
25 Aug 2006 1:47 AM
GhostInAK
Hello RaoulDuke,

My final thoughts on this:

1.  Either implement your own wrapper for the Win32 Common Control (checkbox)..
implementing uxtheme.dll functions for the XP look, etc..

or

2.  Derive a new control from checkbox.. (or if its not inheritable, add
hacks to the form code) which makes it so the value can not be changed using
the UI (at runtime).. then just change the checkbox's forecolor.. a nice
bright RED should indicate that these values are not to be touched.. and
the electric cattle prod wired into the user's chair will ensure they get
the message.

-Boo

Show quoteHide quote
> *bounce*    Still hoping for some help on this.  It seems it is much
> harder than it should be.  Searching this forum, I see other people
> have had the same question in the past, but I haven't really found a
> suitable answer.
>
> The one way that almost works is to remove the text associated with
> the checkbox and put a label there instead.  Then you can set the
> enabled property to false which gives the gray look nicely.  The only
> trouble is the checkmark also becomes grayed out and too difficult to
> see properly.
>
> Thoughts?
>
> RaoulDuke wrote:
>
>> Yea, I think that I will have to make a new control class and start
>> by inheriting the standard checkbox control.  However, I don't know
>> how to override the paint procedure...
>>
>> GhostInAK wrote:
>>
>>> Hello RaoulDuke,
>>>
>>> Override the control's paint procedure.
>>>
>>> It may be best to just make a new control.
>>>
>>> -Boo
>>>
>>>> GhostInAK wrote:
>>>>
>>>>> Hello schae***@hotmail.com,
>>>>>
>>>>> Check out CheckBox.Enabled
>>>>>
>>>>> -Boo
>>>>>
>>>> While that is the look of the box that I want, I still need the
>>>> text and the check to be in black.  I believe I can still alter the
>>>> Checkbox.checked state even if it was disabled, so if you can tell
>>>> me how to get the text / check to black?
>>>>
Author
25 Aug 2006 2:54 PM
Claes Bergefall
If you don't really need a checkbox but rather something that looks like
one, you might be able to use the ControlPaint class and just draw one in
whatever state you want it it.

   /claes

Show quoteHide quote
"RaoulDuke" <schae***@hotmail.com> wrote in message
news:1156442230.498976.168300@75g2000cwc.googlegroups.com...
> *bounce*    Still hoping for some help on this.  It seems it is much
> harder than it should be.  Searching this forum, I see other people
> have had the same question in the past, but I haven't really found a
> suitable answer.
>
> The one way that almost works is to remove the text associated with the
> checkbox and put a label there instead.  Then you can set the enabled
> property to false which gives the gray look nicely.  The only trouble
> is the checkmark also becomes grayed out and too difficult to see
> properly.
>
> Thoughts?
>
>
> RaoulDuke wrote:
>> Yea, I think that I will have to make a new control class and start by
>> inheriting the standard checkbox control.  However, I don't know how to
>> override the paint procedure...
>>
>>
>> GhostInAK wrote:
>> > Hello RaoulDuke,
>> >
>> > Override the control's paint procedure.
>> >
>> > It may be best to just make a new control.
>> >
>> > -Boo
>> >
>> > > GhostInAK wrote:
>> > >
>> > >> Hello schae***@hotmail.com,
>> > >>
>> > >> Check out CheckBox.Enabled
>> > >>
>> > >> -Boo
>> > >>
>> > > While that is the look of the box that I want, I still need the text
>> > > and the check to be in black.  I believe I can still alter the
>> > > Checkbox.checked state even if it was disabled, so if you can tell me
>> > > how to get the text / check to black?
>> > >
>