14

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

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Hatem Hidouri
  • 143
  • 1
  • 1
  • 5

3 Answers3

18

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;
Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
  • Does it look and behave properly also on Windows XP ? [+1] – TLama Dec 08 '12 at 20:22
  • @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?) – Andreas Rejbrand Dec 08 '12 at 20:23
  • Thanks Andreas, is there a way to modify the border size? – Hatem Hidouri Dec 12 '12 at 10:54
  • @HatemHidouri: That's an OS-wide setting (probably per-user). – Andreas Rejbrand Dec 12 '12 at 11:01
  • 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. – VitorMM Mar 03 '20 at 16:14
3

Set BorderStyle to bsNone in Object Inspector

iMan Biglari
  • 4,674
  • 1
  • 38
  • 83
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.

Smaniotto
  • 31
  • 1