Solved

Simple TCheckBox Question

Posted on 2002-03-25
5
348 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month7 days, 13 hours left to enroll

632 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