Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple TCheckBox Question

Posted on 2002-03-25
5
Medium Priority
?
362 Views
Last Modified: 2010-04-04
Hi

I'm looking to find a way of changing the background colour on the 'checked' part of the TCheckBox, from it's default white.

Does anyone know how either to add this additional property to the component or better still a 3rd party component already available.

Thanks in advance.

Palin
0
Comment
Question by:palin2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6895201
Hi Palin,

I'm fairly sure there is no way to change the component itself, but you maybe able to create your own TCheckbox derived from TCustomCheckbox.

I'm sure there are HEAPS of checkbox components around which allow you to do this.  The one I use (which isn't DB aware) is called TBitCheckBox.  It ships with two different sets of state bitmaps (checked, unchecked, greyed, disabled) but you can specify your own (just whip them up in MS Paint or something similar).

If you'd like a copy, email me at gtho1971@hotmail.com and I'll email you a copy of it.

Stu
0
 
LVL 5

Accepted Solution

by:
alanwhincup earned 200 total points
ID: 6897073
Below ive done a quick example on how to draw on to the CheckBox control by creating a TCheckbox decendent and overriding the paint handler. You may beable to adapt it to draw your required box peice:

type
  TNewCheckBox = class(TCheckBox)
  private
    procedure WMPaint(var Message : TWMPaint); message WM_PAINT;
  end;

var
  ChkBox : TNewCheckBox;

...

procedure TNewCheckBox.WMPaint(var Message : TWMPaint);
var
  PS : PaintStruct;
begin
  with Message do begin
    DC := BeginPaint(Self.Handle, PS);
    DrawText(DC, 'Test Text', -1, PS.rcPaint, DT_VCENTER or DT_SINGLELINE);
  end;
  EndPaint(Self.Handle, PS);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ChkBox := TNewCheckBox.Create(Self);
  with ChkBox do
  begin
    Parent := Form1;
    Caption := 'Test';
    Width := 100;
    Height := 20;
    Left := 10;
    Top := 10;
  end;
end;

I'm not sure if it works because I currently can't test it but it should do.

Cheers,

Alan
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6897707
Nice, Alan, very nice!
0
 

Expert Comment

by:CleanupPing
ID: 9343222
palin2000:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 7

Expert Comment

by:knightmad
ID: 9471004
Wow, Its been a long time since this comment have been visited!

palin2000,
No comment has been added lately (19 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to alanwhincup http:#6897073

-- Please DO NOT accept this comment as an answer ! --

Thanks,

knightmad
EE Cleanup Volunteer

Remember you (all) can object this recommendation if you disagree, just leave a post here explaining why are you objecting and what should be done instead.
Within 7 days probably this thread will be closed, so, hurry up! : )
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question