Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple TCheckBox Question

Posted on 2002-03-25
5
Medium Priority
?
370 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
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 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