unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
protected
procedure RebuildWindowRgn;
procedure Resize; override;
public
constructor Create(AOwner:TComponent);override;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
constructor TForm1.Create(AOwner:TComponent);
begin
inherited;
HorzScrollbar.Visible := false;
VertScrollbar.Visible := false;
RebuildWindowRgn;
end;
procedure TForm1.Resize;
begin
inherited;
RebuildWindowRgn;
end;
procedure TForm1.RebuildWindowRgn;
var
FullRgn, Rgn: THandle;
ClientX, ClientY, i: integer;
begin
ClientX:=(Width-ClientWidth) div 2;
ClientY:=Height-ClientHeight-ClientX;
FullRgn:=CreateRectRgn(0,0,Width,Height);
Rgn:=CreateRectRgn(ClientX,ClientY,ClientX+ClientWidth,
ClientY+ClientHeight);
CombineRgn(FullRgn,FullRgn,Rgn,RGN_DIFF);
for i:=0 to ControlCount-1 do
with Controls[i] do
begin
Rgn:=CreateRectRgn(ClientX+Left,ClientY+Top,
ClientX+Left+Width,ClientY+Top+Height);
CombineRgn(FullRgn,FullRgn,Rgn,RGN_OR);
end;
SetWindowRgn(Handle,FullRgn,true);
end;
end.
|