firemonkey EDit 改变颜色

Posted 夜郎王子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了firemonkey EDit 改变颜色相关的知识,希望对你有一定的参考价值。

PS:本来不应该有多难,结果折腾了半天,

firemonkey EDit  Canvas 按需绘颜色

 

 

procedure TForm.EditPaint(Sender: TObject; Canvas: TCanvas;
  const ARect: TRectF);
  var
    ARect1: TRectF;
begin
   //绘制颜色
   (Sender as TEdit).BeginUpdate;
   ARect1:=ARect;
   ARect1.Left:=1;
   ARect1.Top:=1;
   ARect1.Bottom:=ARect.Bottom-1;
   ARect1.Right:=ARect.Right-1;


     if (Sender as TEdit).Text= ((Sender as TEdit).Data.ToString)  then
      begin
         Canvas.Fill.Kind := TBrushKind.Solid;
         Canvas.Fill.Color := TAlphaColorRec.Blue;
         Canvas.FillRect(ARect1, 0, 0, [], 1);
         (Sender as TEdit ).FontColor:=TAlphaColorRec.red;
      end
      else
      begin
        // Canvas.Fill.Kind := TBrushKind.Solid;
         Canvas.Fill.Color := TAlphaColorRec.Red;
         Canvas.FillRect(ARect1, 0, 0, [], 1);
         (Sender as TEdit ).FontColor:=TAlphaColorRec.blue;
      end;

   Canvas.Fill.Color := TAlphaColorRec.Black;
   Canvas.Font.Size:=12;
    Canvas.FillText(ARect1, (Sender as tedit).Text, false,1, [], TTextAlign.Center, TTextAlign.Center);
   (Sender as TEdit).EndUpdate;
end;

  

 

以上是关于firemonkey EDit 改变颜色的主要内容,如果未能解决你的问题,请参考以下文章

[修正] Firemonkey Windows & macOS 平台下 Edit & Memo 中文输入后会取消原选取文字的 BUG

[修正] Firemonkey Android Edit 可输入 Emoji (颜文字)

[范例] Firemonkey Edit 输入框只允许输入数字 for Android

Firemonkey (FMX) 位图和颜色

Firemonkey TEdit 大写

改变TLabel字型和颜色(Styled特性高于自身特性,李维的博客)