Kod: Tümünü seç
Function Form_Transparent(Form: TForm; Transparent: Boolean): Boolean;
Var
AControl: TControl;
A, Margin, X, Y, CtlX, CtlY: Integer;
FullRgn, ClientRgn, CtlRgn: THandle;
Begin
With Form Do
If Transparent Then
Begin
Margin := (Width - ClientWidth) div 2;
FullRgn := CreateRectRgn(0, 0, Width, Height);
X := Margin;
Y := Height - ClientHeight - Margin;
ClientRgn:= CreateRectRgn(X, Y, X + ClientWidth, Y + ClientHeight);
CombineRgn(FullRgn, FullRgn, ClientRgn, RGN_DIFF);
For A:= 0 To ControlCount - 1 Do
Begin
AControl:= Controls[A];
If (AControl Is TWinControl) Or (AControl Is TGraphicControl) Then
With AControl Do
Begin
If Visible Then
Begin
CtlX := X + Left;
CtlY := Y + Top;
CtlRgn:= CreateRectRgn(CtlX, CtlY, CtlX + Width, CtlY + Height);
CombineRgn(FullRgn, FullRgn, CtlRgn, RGN_OR);
End;
End;
End;
SetWindowRgn(Handle, FullRgn, True);
End
Else
Begin
FullRgn:= CreateRectRgn(0, 0, Width, Height);
CombineRgn(FullRgn, FullRgn, FullRgn, RGN_COPY);
SetWindowRgn(Handle, FullRgn, True);
End;
Result:= Transparent;
End;