Mirror

How do I make transparent forms? (Views: 101)


Problem/Question/Abstract:

How do I make transparent forms?

Answer:

You need to override the CreateParam function and there add WS_EX_TRANSPARENT
to the Params.ExStyle.

Set the form's canvas' Brush.Style to bsClear, as shown in this example:

type
  TMyForm = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure CreateParams(var Params: TCreateParams); override;
  end;

procedure TMyForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  // this is the important constant!
  Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TMyForm.FormCreate(Sender: TObject);
begin
  inherited;
  Canvas.Brush.Style := bsClear;
end;

<< Back to main page