Recent

Author Topic: [SOLVED] Text Coloring not working on Win X  (Read 1273 times)

Slyde

  • Full Member
  • ***
  • Posts: 152
[SOLVED] Text Coloring not working on Win X
« on: December 20, 2020, 07:18:54 pm »
This code works fine on Linux Mint:

Code: Pascal  [Select][+][-]
  1. j := 1;
  2.   for i := 1 to 20 do
  3.     begin
  4.       tec := Form1.FindComponent('AMC_Edit' + IntToStr(i));
  5.       if tec is TEdit then
  6.       for k := 1 to 4 do
  7.         begin
  8.           rcbc := Form1.FindComponent('AMC_RadioButton' + IntToStr(j));
  9.           Inc(j);
  10.           if ((tec as TEdit).Text <> (rcbc as TRadioButton).Caption) and (rcbc as TRadioButton).Checked then
  11.             begin
  12.               (rcbc as TRadioButton).Font.Color := clRed;
  13.             end;
  14.         end;
  15.     end;

But on Windows, when I run it thru the debugger, I see line 12 execute, but the font color never changes to red.  What am I doing wrong?  :D
« Last Edit: December 20, 2020, 07:39:39 pm by Slyde »
Linux Mint 21.3
Lazarus 3.0

wp

  • Hero Member
  • *****
  • Posts: 13502
Re: Text Coloring not working on Win X
« Reply #1 on: December 20, 2020, 07:33:51 pm »
Because the LCL components are painted by the widgetset there is limited control. In case of Windows you cannot change the text color of a TRadioButton. The object inspector has a page "Restrictions" listing the properties which cannot be changed in the current widgetset.

If you absolutely need a radiobutton  with colored text you could install the package ExCtrls (available via OPM) which contains custom drawn radiobuttons/checkboxes and offers a lot of flexibility (and is cross-platform, of course): https://wiki.lazarus.freepascal.org/ExCtrls#TRadioButtonEx.2C_TCheckBoxEx.2C_TRadioGroupEx_and_TCheckGroupEx.

Slyde

  • Full Member
  • ***
  • Posts: 152
Re: Text Coloring not working on Win X
« Reply #2 on: December 20, 2020, 07:39:13 pm »
Thanks for the heads up, wp.  I have that package installed, just haven't used anything out of it.  I'll check it out.  Thanks again.   
Linux Mint 21.3
Lazarus 3.0

 

TinyPortal © 2005-2018