delphi 控件圆角

procedure TForm1.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);       //缩小R 5

    Perform(EM_SETRECTNP, 0, LParam(@R));  //消息等于EM_SETRECT,但是不会发生重绘事件

    SetWindowRgn(Control.Handle, Rgn, True);

    Invalidate;

    {-------------

    Perform(EM_SETRECT, 0, LParam(@R));

    ----------------------}

  end;

  //传入控件的name和两个弧度就可以设置控件的圆角效果

end;

 

你可能感兴趣的:(Delphi)