7

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?

Ron
  • 14,674
  • 4
  • 34
  • 47
ReA
  • 73
  • 1
  • 3
  • I need WS_THICKFRAME to me the form resizable. – ReA Oct 22 '17 at 14:32
  • Setting the border style to `bsNone` makes the window not resizable. Explore the `bsToolWindow` and `bsSizeToolWin` alternatives. Going down the WinAPI route can prove to be a lot of work. – Ron Oct 22 '17 at 14:44
  • And the form can be moved as well, right? – Nasreddine Galfout Oct 22 '17 at 18:09
  • Yes, but moving the form is straight forward using WMNCHitTest. My problem is the white bar at top edge. – ReA Oct 22 '17 at 18:13
  • @Ron: bsToolWindow or bsSizeToolWin won't remove the tilebar. – ReA Oct 22 '17 at 18:15
  • Have you considered handling `WM_NCPAINT` and possibly `WM_NCACTIVATE` messages, painting the border the same color as your client area bg? I haven't tried with Win 10 (and can't do so right now) – Tom Brunberg Oct 22 '17 at 18:56
  • It's been a while since you asked that but I created a repository with a solution without VCLStyles... Take a look on [my repository](https://github.com/matheusrmribeiro/DelphiProjects) and if you want I opened a [question](https://stackoverflow.com/questions/54655376/create-a-borderless-form-without-losing-windows-commands/54673991#54673991) here too – Matheus Miranda Feb 21 '19 at 16:44

4 Answers4

6

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.

Nasreddine Galfout
  • 2,550
  • 2
  • 18
  • 36
1

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
CaptureWiz
  • 1,685
  • 1
  • 15
  • 15
-1

It is not handled by Delphi on Windows 10! You must use a tweak tool to control the border size inside windows. I used winaero (www.winaero.com) and reduce the window border to 1 and padding to zero. enter image description here

fmw42
  • 46,825
  • 10
  • 62
  • 80
cuebit
  • 1
-1

for firemonkey (fmx) users: You can do this via styles.

Edward
  • 247
  • 1
  • 11