How to remove the title bar from a form

11,790

Solution 1

First, set BorderStyle to bsNone at design-time. Then declare the procedure CreateParams like so:

type
  TForm1 = class(TForm)
  private
  protected
    procedure CreateParams(var Params: TCreateParams); override; // ADD THIS LINE!
    { Private declarations }
  public
    { Public declarations }
  end;

and implement it like

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style or WS_THICKFRAME;
end;

Solution 2

Set BorderStyle to bsNone in Object Inspector

Solution 3

For better border style, you can add the WS_BORDER flag.

Like this:

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style or WS_BORDER or WS_THICKFRAME;
end;

Note than a soft line is drawn inside the border frame.

Share:
11,790

Related videos on Youtube

Hatem Hidouri
Author by

Hatem Hidouri

Updated on June 04, 2022

Comments

  • Hatem Hidouri
    Hatem Hidouri almost 2 years

    Does anyone know how to create a Delphi form without a title bar? I have seen some some links/tips but its not exactly what I want and I couldn't do it myself.

    This is what I am trying to achieve:

    enter image description here

  • Andreas Rejbrand
    Andreas Rejbrand over 11 years
    That alone isn't sufficient.
  • Andreas Rejbrand
    Andreas Rejbrand over 11 years
    Compare the result with the image supplied by the OP. The entire glass border (and shadow) is gone.
  • TLama
    TLama over 11 years
    Does it look and behave properly also on Windows XP ? [+1]
  • Andreas Rejbrand
    Andreas Rejbrand over 11 years
    @TLama: Don't remember and have no XP to test on, but there shouldn't be any problems, I think. (Doesn't it get a blue thick border instead of the glass one?)
  • Hatem Hidouri
    Hatem Hidouri over 11 years
    Thanks Andreas, is there a way to modify the border size?
  • Andreas Rejbrand
    Andreas Rejbrand over 11 years
    @HatemHidouri: That's an OS-wide setting (probably per-user).
  • Hatem Hidouri
    Hatem Hidouri over 11 years
    I see now. Thank you again
  • VitorMM
    VitorMM about 4 years
    I know this is a pretty old question, but just confirming: it does work in XP, although it does not create the regular blue thick border. Instead, it creates a grey thiner border (Params.Style or WS_BORDER or WS_THICKFRAME also does that). Still resizable thought.