控件组合的异形不规则窗体
procedure TForm1.FormCreate(Sender: TObject);
var
FullRgn, ClientRgn, ButtonRgn: THandle;
LeftMargin,TopMargin:Integer;
Margin, X, Y: Integer;
i:integer;
begin
Margin := (Width - ClientWidth) div 2;
FullRgn := CreateRectRgn(0, 0, Width, Height);
LeftMargin := Margin;
TopMargin := Height - ClientHeight - Margin;
ClientRgn := CreateRectRgn(LeftMargin, TopMargin, LeftMargin + ClientWidth, TopMargin + ClientHeight);
CombineRgn(FullRgn, FullRgn, ClientRgn, RGN_DIFF);
for i:= 0 to ComponentCount-1 do
begin
if not (Components[i] is TWinControl) then continue;
if (Components[i] as TWinControl).Parent<>self then continue;
X := LeftMargin + (Components[i] as TWinControl).Left;
Y := TopMargin + (Components[i] as TWinControl).Top;
ButtonRgn := CreateRectRgn(X, Y, X + (Components[i] as TWinControl).Width, Y + (Components[i] as TWinControl).Height);
CombineRgn(FullRgn, FullRgn, ButtonRgn, RGN_OR);
end;
SetWindowRgn(Handle, FullRgn, True);
end;