给个例子 按自己要求改一改就OK了
procedure TForm1.FormCreate(Sender: TObject);
const
bgcolor = $00FFDDEE;
linecolor = $00554366;
var
img: array of TImage;
reg: hrgn;
i: Integer;
begin
for i := 0 to ComponentCount - 1 do
begin
if Components.ClassName = 'TPanel' then
begin
setlength(img, Length(img) + 1);
img := TImage.Create(Self);
img.Width := (Components as TPanel).Width;
img.Height := (Components as TPanel).Height;
img.Parent := (Components as TPanel);
img.Canvas.Brush.Color := bgcolor;
img.Canvas.pen.Color := bgcolor;
img.Canvas.Rectangle(0,0,img.Width, img.Height);
img.Canvas.pen.Color := linecolor;
img.Canvas.RoundRect(0,0,img.Width - 1,img.Height - 1,20,20);
reg := CreateRoundRectRgn(0,0,(Components as TPanel).Width,
(Components as TPanel).Height, 20,20);
setwindowrgn((Components as TPanel).Handle, reg, True);
deleteobject(reg);
end;
end;
end;