firemonkey EDit 改变颜色

2018-06-17 18:55:58来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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).Hint)  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;

  

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:[示例] Firemonkey ListView 仿 iPhone X 浏海

下一篇:Delphi中按键定义