delphi实现圆角窗体[转]
2021-02-05 08:16
标签:procedure sel set 定义 RoCE null end width delete procedure TForm1.FormCreate(Sender: TObject); procedure TForm1.FormPaint(Sender: TObject); delphi实现圆角窗体[转] 标签:procedure sel set 定义 RoCE null end width delete 原文地址:https://www.cnblogs.com/blogpro/p/11446818.html
var
hr :thandle;
begin
hr:=createroundrectrgn(1,1,width-2,height-2,5,5);
setwindowrgn(handle,hr,true);
end;
var
DC: HDC;
Pen: HPen;
OldPen: HPen;
OldBrush: HBrush;
begin
DC := GetWindowDC(Handle);
Pen := CreatePen(PS_SOLID, 1, clGray);
OldPen := SelectObject(DC, Pen); //载入自定义的画笔,保存原画笔
OldBrush := SelectObject(DC, GetStockObject(NULL_BRUSH));//载入空画刷,保存原画刷
RoundRect(DC, 0, 0, Width-1, Height-1, 6, 6); //画边框
SelectObject(DC,OldBrush);//载入原画刷
SelectObject(DC,OldPen); // 载入原画笔
DeleteObject(Pen);
ReleaseDC(Handle, DC);
end;