鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > delphi > >

firemonkey EDit 改变颜色

来源:互联网 作者:佚名 时间:2017-09-02 12:29
PS:本来不应该有多难,结果折腾了半天, firemonkey EDit Canvas 按需绘颜色 procedure TForm.EditPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF); var ARect1: TRectF;begin //绘制颜色 (Sender as TEdit).BeginUpdate; ARect1:=ARect; ARe

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;

  

 

网友评论
<