Firemonkey tEdit OnPaint

时间:2019-02-02 20:49:18

标签: firemonkey paint rad-studio

我有一个tEdit,我想用FillStroke不同的颜色来绘制它的矩形。我的编码如下:

procedure TForm1.FormCreate (Sender: TObject);
begin
  Edit1.OnPaint := HandleEditPaint;
end;

procedure TForm1.HandleEditPaint (Sender: tObject; Canvas: tCanvas; const aRect: tRectF);
begin
  Canvas.BeginScene;
  Canvas.Fill  .Color := TAlphaColorRec.Aqua;
  Canvas.Fill  .Kind  := TBrushKind.bkSolid;
  Canvas.Stroke.Color := TAlphaColorRec.Red;
  Canvas.Stroke.Kind  := TBrushKind.bkSolid;
  Canvas.FillRect (aRect, 0, 0, AllCorners, 1, TCornerType.Bevel);
  Canvas.DrawRect (aRect, 0, 0, AllCorners, 1, TCornerType.Bevel);
  Canvas.EndScene;
end;

它可以正确地绘制控件的矩形,但是不能集中注意力,因为在单击控件时,它会进入触发HandleEditPaint不停的循环。我如何避免这种情况发生?我知道在绘制控件的矩形时,我也必须照顾控件的文本,但是我也应该关心鼠标光标吗?有没有一种使用样式来实现此行为的方法?

0 个答案:

没有答案