Board index » delphi » Edit box selected text color

Edit box selected text color

Hi there,

Is there a way to change the selected text apperance (color &
backgroupd) of an edit box OTHER THAN changing the colors in the coltrol
panel/Display settings. Because I do not want to have a system-wide
modification, just my app.

thanks in advance
Didier

 

Re:Edit box selected text color


simply use GetPropinfo and SetPropInfo to change the color property of the
component before dropping it.

e.g

procedure SetActiveColors
    (AComponent : TWinControl);
  var
    ColourPropInfo: PPropInfo;
  begin

     // see if we've got a colour property
 ColourPropInfo := GetPropInfo(AComponent.ClassInfo, COLOUR_PROPERTY_NAME);
 if assigned(ColourPropInfo) then begin
          SetOrdProp(AComponent, ColourPropInfo, 'Color');
  end;

Quote
"Didier Gasser-Morlay" <didie...@nordnet.fr> wrote in message

news:3C48ABA6.7090505@nordnet.fr...
Quote
> Hi there,

> Is there a way to change the selected text apperance (color &
> backgroupd) of an edit box OTHER THAN changing the colors in the coltrol
> panel/Display settings. Because I do not want to have a system-wide
> modification, just my app.

> thanks in advance
> Didier

Re:Edit box selected text color


Correction.. lol

add TypInfo to your Uses clause and the rest will change an edit control to
be red. I am sure you can
figure out the rest to loop through the controls on the form. and other
propinfo's for text etc.

procedure TForm1.SetActiveColors(AComponent : TWinControl);
var
  ColourPropInfo: PPropInfo;
begin
 // see if we've got a colour property
 ColourPropInfo := GetPropInfo(AComponent.ClassInfo, 'Color');
 if assigned(ColourPropInfo) then
   SetOrdProp(AComponent, ColourPropInfo, clRed);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetACtiveColors(Edit1);
end;

Quote
"Didier Gasser-Morlay" <didie...@nordnet.fr> wrote in message

news:3C48ABA6.7090505@nordnet.fr...
Quote
> Hi there,

> Is there a way to change the selected text apperance (color &
> backgroupd) of an edit box OTHER THAN changing the colors in the coltrol
> panel/Display settings. Because I do not want to have a system-wide
> modification, just my app.

> thanks in advance
> Didier

Re:Edit box selected text color


Martin,

This will change the edit box color, font ... but unless I did not get
what you suggest, I am after changing the colors uses when SELECTING the
text inside the edit box.

Sorry I was ot clear enough
Didier

Quote
Martin Dew wrote:
> Correction.. lol

> add TypInfo to your Uses clause and the rest will change an edit control to
> be red. I am sure you can
> figure out the rest to loop through the controls on the form. and other
> propinfo's for text etc.

> procedure TForm1.SetActiveColors(AComponent : TWinControl);
> var
>   ColourPropInfo: PPropInfo;
> begin
>  // see if we've got a colour property
>  ColourPropInfo := GetPropInfo(AComponent.ClassInfo, 'Color');
>  if assigned(ColourPropInfo) then
>    SetOrdProp(AComponent, ColourPropInfo, clRed);
> end;

> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   SetACtiveColors(Edit1);
> end;

> "Didier Gasser-Morlay" <didie...@nordnet.fr> wrote in message
> news:3C48ABA6.7090505@nordnet.fr...

>>Hi there,

>>Is there a way to change the selected text apperance (color &
>>backgroupd) of an edit box OTHER THAN changing the colors in the coltrol
>>panel/Display settings. Because I do not want to have a system-wide
>>modification, just my app.

>>thanks in advance
>>Didier

Re:Edit box selected text color


Quote
In article <3C48ABA6.7090...@nordnet.fr>, Didier Gasser-Morlay wrote:
> Is there a way to change the selected text apperance (color &
> backgroupd) of an edit box OTHER THAN changing the colors in the coltrol
> panel/Display settings. Because I do not want to have a system-wide
> modification, just my app.

Only if you are prepared to completely take over the painting of the
control, which is not an easy task. Of course you may be able to find a
ready-made replacement for TEdit on one of the Delphi sites:

   http://www.borland.com/delphi/resources/deltools.html
Delphi Super Page       http://sunsite.icm.edu.pl/delphi/
  US mirror site:       http://www.cdrom.com/pub/delphi_www/
  German mirror :        
http://ftp.uni-erlangen.de/pub/source/MIRRORS/sunsite.icm.edu.pl/pub/...
  Other mirrors :       http://ftp.sunet.se/delphi/
Torry's Delphi Pages    http://www.torry.net/  
                        http://homepages.borland.com/torry/
the Delphi Box          http://Inner-Smile.com .
                        http://www.delphisource.com/
The DELPHI Deli         http://www.delphix.com/
The Delphi EXchange     http://www.delphiexchange.com/
The Delphi Pool         http://www.lmc-mediaagentur.de/dpool.htm

--
Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:Edit box selected text color


aaarrggh! too bad!
Thanks anyway.
Didier
Quote
Peter Below (TeamB) wrote:
> In article <3C48ABA6.7090...@nordnet.fr>, Didier Gasser-Morlay wrote:

>>Is there a way to change the selected text apperance (color &
>>backgroupd) of an edit box OTHER THAN changing the colors in the coltrol
>>panel/Display settings. Because I do not want to have a system-wide
>>modification, just my app.

> Only if you are prepared to completely take over the painting of the
> control, which is not an easy task. Of course you may be able to find a
> ready-made replacement for TEdit on one of the Delphi sites:

>    http://www.borland.com/delphi/resources/deltools.html
> Delphi Super Page       http://sunsite.icm.edu.pl/delphi/
>   US mirror site:       http://www.cdrom.com/pub/delphi_www/
>   German mirror :        
> http://ftp.uni-erlangen.de/pub/source/MIRRORS/sunsite.icm.edu.pl/pub/...
>   Other mirrors :       http://ftp.sunet.se/delphi/
> Torry's Delphi Pages    http://www.torry.net/  
>                         http://homepages.borland.com/torry/
> the Delphi Box          http://Inner-Smile.com .
>                         http://www.delphisource.com/
> The DELPHI Deli         http://www.delphix.com/
> The Delphi EXchange     http://www.delphiexchange.com/
> The Delphi Pool         http://www.lmc-mediaagentur.de/dpool.htm

> --
> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!
> Use the newsgroup archives :
> http://www.mers.com/searchsite.html
> http://www.tamaracka.com/search.htm
> http://groups.google.com
> http://www.prolix.be

Other Threads