How to remove the title bar from a form
Asked Answered
P

3

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

Paraphrase answered 8/12, 2012 at 20:3 Comment(0)
I
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;
Interrogatory answered 8/12, 2012 at 20:17 Comment(5)
Does it look and behave properly also on Windows XP ? [+1]Doy
@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?)Interrogatory
Thanks Andreas, is there a way to modify the border size?Paraphrase
@HatemHidouri: That's an OS-wide setting (probably per-user).Interrogatory
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.Oubre
S
3

Set BorderStyle to bsNone in Object Inspector

Serrell answered 8/12, 2012 at 20:13 Comment(2)
That alone isn't sufficient.Interrogatory
Compare the result with the image supplied by the OP. The entire glass border (and shadow) is gone.Interrogatory
M
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.

Mown answered 23/6, 2016 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.