Topic: Changing Disabled Field Font Color

Hi all,
.
I was hoping someone has tried this before, but I was unable to find any related posts.
.
I'm trying to change the font color for a field that has the enable property set to false.
.
These are the things that I have tried already:

  • manually changing the font color in the field's property

  • using an OnChange event for the tablegrid related to the field

.
I don't have any other ideas to try, so I thought I would ask.
.
Normally shading the disabled fields is desirable, but I have a case where a different color would be helpful.

Post's attachments

Attachment icon disabled-font-color.png 1.44 kb, 84 downloads since 2021-09-11 

"Energy and persistence conquer all things."

2 (edited by derek 2021-09-11 11:33:51)

Re: Changing Disabled Field Font Color

Hi Joshua,
Once you've set a field to enabled := false then I don't believe you can change the font colour;  you can however, change the background colour which might be an option.
If it's the actual font colour you want to change, instead of setting the field to enabled := false, you could set the field to readonly := true;  this does allow you to change the font colour.
Be aware that this only works with edit fields, memo fields and comboboxes.  If I remember rightly, it doesn't work with checkboxes nor dates (a Windows restriction rather than MVD, I believe).
Derek.

Re: Changing Disabled Field Font Color

Hi derek,
.
That's what I was looking for.  I overlooked the ReadOnly property.  I was getting it confused with the Enabled property which doesn't allow the field text to be selected.  This way the contents may still be selected and copied.
.
Many thanks!

Post's attachments

Attachment icon read-only-font-color.png 1.17 kb, 84 downloads since 2021-09-11 

"Energy and persistence conquer all things."

Re: Changing Disabled Field Font Color

While experimenting further with this, I noticed that MVD will create a clickable link to http urls.  This is neat, but I was trying to get this working for mailto links as well...
.
I found other posts that have done this (opening an e-mail client) using scripts, but I was wondering if there was a way to get MVD to do it natively before I use scripting for it.
.
I have tried appending the mailto: portion to the front of the field as well as saving it in the field data, but neither seem have the same result as the http:// links do.
.
Any thoughts?

Post's attachments

Attachment icon mailto-http.png 2.57 kb, 83 downloads since 2021-09-11 

"Energy and persistence conquer all things."

5 (edited by vovka3003 2021-09-11 18:59:29)

Re: Changing Disabled Field Font Color

Только скрипт.

procedure Mailto(Sender: TObject);
begin
   OpenFile('mailto:'+TdbEdit(Sender).Text,'');
end;

procedure EdMouseEnter (Sender: TObject);
begin
  with TEdit(Sender) do
  begin
      if pos('@',Text) = 0 then exit;
      Font.Color := clBlue;
      Font.Style :=  fsUnderline;
      Cursor := crHandPoint;
      OnDblClick := @Mailto;
  end;
end;

procedure EdMouseLeave(Sender: TObject);
begin
 with TEdit(Sender) do
  begin
       Font.Color := clDefault;
       Font.Style :=   0;
       Cursor := crDefault;
       OnDblClick := nil;
   end;
end;

procedure IsMailFields(Flds:array of TdbEdit);
var i:integer;
begin
  for i:=0 to  length(Flds)-1 do
  begin
    Flds[i].OnMouseEnter := @EdMouseEnter;
    Flds[i].OnMouseLeave := @EdMouseLeave;
  end;
end;

begin



 IsMailFields([
       // Здеь поля email через запятую:
      Form1.Edit1,
      Form1.Edit2
      // ...
 ]);

end.

https://i.imgur.com/LP2ew6I.png

Re: Changing Disabled Field Font Color

Awesome.  Thanks vovka3003.  That's even more simple than the scripts I have found.

"Energy and persistence conquer all things."