Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Invert the color of a TEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
06-Nov-02
Category
VCL-General
Language
Delphi 2.x
Views
81
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have a TEdit control and there are two color properties I wish to set: 
TEdit.Color and TEdit.Font.Color. I did something like

TEdit.Color := clBlack
TEdit.Font.Color := TEdit.Color xor $7FFFFFFF;

but TEdit.Font.Color doesn't show as contrast of TEdit.Color. Can anybody advise on 
that. I wish to make the TEdit.Color and TEdit.Font.Color always contrast to each 
other. My application allows the user to change the TEdit.color at runtime.

Answer:

Try this one:

1   function InverseColor(color: TColor): TColor;
2   var
3     rgb_: TColorRef;
4   
5     function Inv(b: Byte): Byte;
6     begin
7       if b > 128 then
8         result := 0
9       else
10        result := 255;
11    end;
12  
13  begin
14    rgb_ := ColorToRgb(color);
15    rgb_ := RGB(Inv(GetRValue(rgb_)), Inv(GetGValue(rgb_)), Inv(GetBValue(rgb_)));
16    Result := rgb_;
17  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC