procedure TransparentPanel(var Target : TPanel);
  var
    I : Integer;
    FullRgn, ClientRgn, ControlRgn : THandle;
    Margin, MarginX, MarginY, X, Y : Integer;
  begin
    Margin  := (Target.Width - Target.ClientWidth) div 2;
    FullRgn := CreateRectRgn(0, 0, Target.Width, Target.Height);
    MarginX := Margin;
    MarginY := Target.Height - Target.ClientHeight - Margin;
    ClientRgn :=
      CreateRectRgn(
        MarginX
        , MarginY
        , MarginX + Target.ClientWidth
        , MarginY + Target.ClientHeight
      );

    CombineRgn(FullRgn, FullRgn, ClientRgn, RGN_DIFF);

    for I:=0 to Target.ControlCount-1 do begin
      X := MarginX + Target.Controls[I].Left;
      Y := MarginY + Target.Controls[I].Top;
      ControlRgn :=
        CreateRectRgn(
          X
          , Y
          , X + Target.Controls[I].Width
          , Y + Target.Controls[I].Height
        );
      CombineRgn(FullRgn, FullRgn, ControlRgn, RGN_OR);
    end;

    SetWindowRgn(Target.Handle, FullRgn, True);
  end;

 

원본 : 어느 고수님.. 

+ Recent posts