Recent

Author Topic: How to make a TForm with no caption [SOLVED]  (Read 2700 times)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
How to make a TForm with no caption [SOLVED]
« on: July 12, 2017, 09:18:56 pm »
Lazarus 1.8.0 RC3
FPC 3.0.2
macOS 10.12.5

Hello, I am trying to make a TForm with no caption. I've tried setting Caption := ''; and setting BorderIcons := [];, as I've seen it suggested that that works on some platforms. It doesn't work on macOS 10.12.5, however. Obviously Win32 solutions like playing around with SetWindowsLong, GWL_STYLE and WS_CAPTION are not available here, so I really don't know where else to look. Can anyone help?
« Last Edit: July 12, 2017, 10:10:59 pm by carl_caulkett »
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: How to make a TForm with no caption [SOLVED]
« Reply #1 on: July 12, 2017, 10:10:42 pm »
I have found a solution, and it was surprisingly easy.

In an overidden Create method or an OnCreate event handler, set the following properties:

BorderIcons := [];
BorderStyle := bsNone;
FormStyle := fsStayOnTop;
ShowInTaskBar := stNever;
ControlStyle := ControlStyle - [csSetCaption];

I'm using the form as the drop down part of a do-it-yr-self combobox type thing so the vertical positioning has to be done carefully but this can easily be done relative to the underlying control's ClientOrigin.Y property.

 
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to make a TForm with no caption [SOLVED]
« Reply #2 on: July 12, 2017, 10:25:21 pm »
I think you would use less resources if you derived your drop-down combobox-type-thing from TCustomControl rather than from TForm or TCustomForm.

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 306
Re: How to make a TForm with no caption [SOLVED]
« Reply #3 on: July 13, 2017, 12:10:41 pm »
I may well do that next, Howard. I was just after a quick win!
"It builds... ship it!"

Mac Mini M1
macOS 13.6 Ventura
Lazarus 2.2.6 (release version)
FPC 3.2.2 (release version)

 

TinyPortal © 2005-2018