Search code examples
pascallazarusfreepascal

How to make transparent form in lazarus?


I want to make my form transparent. Then when i make AlphaBlend is true, all of component is transparent. How to make the form is transparent except for the component?

Form in lazarus


Solution

  • Windows solution:

    uses Windows;
    
    ...
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Color:=clRed;
    SetWindowLongPtr(Self.Handle, GWL_EXSTYLE,GetWindowLongPtr(Self.Handle, GWL_EXSTYLE) or WS_EX_LAYERED);
    SetLayeredWindowAttributes(Self.Handle, clRed, 0, LWA_COLORKEY);
    end;
    

    Filling the form in red color and creation him transparent.