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
Solved

Simple TCheckBox Question

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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