首页 > 技术文章 > Delphi 使控件变成圆角的方法

windson 2020-03-24 21:40 原文

procedure  RoundControl(Control: TWinControl; arc1, arc2: Integer);
var
  R: TRect;
  Rgn: HRGN;
begin
  with Control do
  begin
    R := Control.ClientRect;
    Rgn := CreateRoundRectRgn(R.Left, R.Top, R.Right, R.Bottom, arc1, arc2);
    Perform(EM_GETRECT, 0, lParam(@R));
    InflateRect(R, -5, -5);
    Perform(EM_SETRECTNP, 0, lParam(@R));
    SetWindowRgn(Control.Handle, Rgn, True);
    Invalidate;
  end;
end;

 

推荐阅读