Recent

Author Topic: [SOLVED] Form without caption  (Read 13539 times)

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
[SOLVED] Form without caption
« on: July 08, 2014, 07:55:20 am »
I have next code

Code: Pascal  [Select][+][-]
  1. ...
  2.     protected
  3.       procedure CreateParams(var Params: TCreateParams); override;
  4. ...
  5. procedure TForm1.CreateParams(var Params: TCreateParams);
  6. begin
  7. {$IFDEF FPC}
  8.   inherited CreateParams(Params);
  9. {$ELSE}
  10.   inherited;
  11. {$ENDIF}
  12.  
  13. with Params do
  14.   begin
  15.     Style:= (Style or WS_POPUP) and not WS_CAPTION;
  16.   end
  17. end;

It's works for D2007, but do not works for CodeTyphon or for Lazarus.

Help me, plz.
« Last Edit: July 14, 2020, 01:41:07 am by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Form without caption
« Reply #1 on: July 08, 2014, 08:34:38 am »
Hmmm.  Didn't know about CreateParams, thanks for the tip...

A quick play shows Form1.BorderStyle := bsNone will give you no Caption, but, errr, doesn't look quite what you're after.

Ahh.  Form1.BorderStyle := bsSizeToolWin; looks more useful for you.

UPDATE: Strange, it worked the first time, but upon repeated tests the Caption is back...
UPDATE2:  I've now tried various things in CreateParams, including playing with ExStyle, wrapping all the consts with Cardinal() and using $0c00000 instead of WS_CAPTION (LCL calculates WS_CAPTION, whereas in MS docs it's a constant).

Nothing I'm afraid.  I'll leave this for people who actually know what they're doing :)
« Last Edit: July 08, 2014, 08:58:42 am by Mike.Cornflake »
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Form without caption
« Reply #2 on: July 08, 2014, 11:33:33 am »
Setting Params.ExStyle with WS_EX_TOOLWINDOW is not respected in the LCL on Win 7.
Perhaps OS themes override this?
Of course you can achieve a blank (wide) form top border by setting
Code: [Select]
with Form1 do
begin
  Caption:='';
  BorderIcons:=[];
end;

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: Form without caption
« Reply #3 on: July 08, 2014, 01:00:03 pm »
Nothing I'm afraid.
Your attempts were successful? Can you show me the code?

2 howardpc
I have added to your code
Code: [Select]
BorderStyle:= bsDialog;
Caption:= '';
BorderIcons:= [];
and got this result (see attachment)

ps. trying to draw a splash screen
pss. My feelings: there is no handler in the Lazarus styles. Is that so?
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Form without caption
« Reply #4 on: July 08, 2014, 01:04:49 pm »
Code: [Select]
BorderStyle=bsNone

for the concerned form at design time, or later in your code.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Form without caption
« Reply #5 on: July 08, 2014, 01:50:26 pm »
ps. trying to draw a splash screen
In that case you want
Code: [Select]
  form1.FormStyle:=fsSplash;
and perhaps other properties set appropriately.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Form without caption
« Reply #6 on: July 08, 2014, 02:07:13 pm »
ps. trying to draw a splash screen
In that case you want
Code: [Select]
  form1.FormStyle:=fsSplash;
and perhaps other properties set appropriately.

The only thing that fsSplash does, is to make sure that the splash form will not become the applications main form, it has no effect on the forms border, caption bar or the caption buttons. As far as I can understand is that LCL tries to enforce some kind of control on what can and can not be done in all widget sets and in some of them you probably can't turn on the borders with out turning on the caption bar as well. I would go looking on the wsXXXXXXXX classes that are the native classes.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: Form without caption
« Reply #7 on: July 08, 2014, 02:23:30 pm »
The only thing that fsSplash does, is to make sure that the splash form will not become the applications main form, it has no effect on the forms border, caption bar or the caption buttons.
I totally agree  ;)

I would go looking on the wsXXXXXXXX classes that are the native classes.

I'll try it

2 ChrisF, howardpc

I need a 3D frame around the window. So I can't use the properties bsNone or fsSplash.

Thanks for the help all you. 
ps. I will be grateful to those who will finally be able to cause the method CreateParams
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Form without caption
« Reply #8 on: July 08, 2014, 03:38:25 pm »
Quote
I need a 3D frame around the window. So I can't use the properties bsNone or fsSplash.

You can paste panel or bevel with 3D frame and anchor it to the edges of the form and set bsNone. It looks a little better.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Form without caption
« Reply #9 on: July 08, 2014, 04:15:29 pm »
@zoltanleo:
I'm not sure about what you mean with "3D frame"...

But in this sample (last post), there is a way to have a window with no caption but a sizeable border (workaround as CreateParams seems to be ineffective):

http://forum.lazarus.freepascal.org/index.php?topic=22196.0

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Form without caption
« Reply #10 on: July 08, 2014, 04:15:33 pm »
Nothing I'm afraid.
Your attempts were successful? Can you show me the code?

I wasn't clear, sorry for that.  None of my attempts were successful, there was always a caption displayed.
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: Form without caption
« Reply #11 on: July 08, 2014, 07:25:57 pm »
Thanks for the tips, friends.   :)
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Form without caption
« Reply #12 on: July 08, 2014, 08:05:53 pm »
A combination of OnCreate and OnActivate as follows gives the form shown below for me (Win 7).

Code: [Select]
implementation

uses LCLType, windows;

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormActivate(Sender: TObject);
begin
  SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and not(WS_DLGFRAME));
  MoveWindow(Handle, Left, Top, Width-1, Height, True);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Caption:='';
  BorderIcons:=[];
  BorderStyle:=bsSizeable;
end;

zoltanleo

  • Hero Member
  • *****
  • Posts: 509
Re: Form without caption
« Reply #13 on: July 09, 2014, 01:46:33 pm »
Wow! This is great!  %)

I have a question: how to disable resize the window?
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa x86_64 (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Form without caption
« Reply #14 on: July 09, 2014, 02:12:00 pm »
borderstyle := bsDialog also I wouldn't use the onactivate at all I think that calling setwindowlong fdrom formcreate should be enough not tested it though so use your own tests.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018