1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.SetRgn;
var
FullRgn, ClientRgn, ButtonRgn: THandle;
Margin, X, Y: Integer;
tp1, tp2 : TPoint;
function MakeRgn(c:TControl):THandle;
var tp,tp2:TPoint;x,y:Integer;
begin
tp1 := Point(Left,top);
tp := c.ClientToScreen(Point(0,0));
x := tp.X-tp1.X;
y := tp.Y-tp1.Y;
Result:=CreateRectRgn(x,y,x+c.Width,y+c.Height);
end;
begin
//边框宽度
Margin := (Width - ClientWidth) div 2;
//整个区域
FullRgn := CreateRectRgn(0, 0, Width, Height);
//中心区域
ClientRgn := MakeRgn(button1);
//裁剪区域
CombineRgn(FullRgn, FullRgn, ClientRgn, RGN_DIFF);
SetWindowRgn(Handle, FullRgn, True);
end;
procedure TForm1.FormResize(Sender: TObject);
begin
setrgn;
end;