Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the top bar from a resizable form on Windows 10?

I am trying to remove title-bar of a form while keeping the border to have a resizable form. I set the BorderStyle to bsNone and override the CreateParams procedure:

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

The only issue I am facing is a white bar on top edge of the form (in win 10):

screenshot

How can I get rid of this white bar?

like image 649
ReA Avatar asked Oct 18 '22 04:10

ReA


2 Answers

Going the win API way will consume a lot of time and can prove to be so hard. If you are willing to go that way I strongly recommend it. But for the current time here is a quick work around to your problem.

Use the VCL Styles by changing the style of the title bar like this

go to Tools-> Bitmap Style Manager and reopen the Windows 10 style (since you want this in windows 10)

Go to Objects-> form->title and change the height to 5.

in your IDE's object inspector uncheck the border Icons and set the caption to ' '.

The result will be a form with a title bar that is so thin, it is a border.

enter image description here

You can further modify the look of the title bar so it looks exactly like the borders.

and see this Vcl.Forms.TFormStyleHook.PaintNC to know exactly how this is done using style Hooks.

like image 196
Nasreddine Galfout Avatar answered Oct 20 '22 13:10

Nasreddine Galfout


In Delphi 11, and possibly earlier, you can create a resizable form without a title bar by using the form's CustomTitleBar property:

Enabled=true
Height=0
ShowCaption=false
ShowIcon=false
SystemButtons=false
SystemColors=false
SystemHeight=false

Form.BorderStyle=bsSizeable
like image 32
CaptureWiz Avatar answered Oct 20 '22 13:10

CaptureWiz