Recent

Author Topic: how to utilize customize form caption row  (Read 2246 times)

Packs

  • Sr. Member
  • ****
  • Posts: 496
how to utilize customize form caption row
« on: September 03, 2024, 08:43:43 am »
I would like to utilize form caption row .

I mean I would like to customize caption of the form .

I have attached the screens  .

if anyone know . please guide me

Zvoni

  • Hero Member
  • *****
  • Posts: 3361
Re: how to utilize customize form caption row
« Reply #1 on: September 03, 2024, 08:53:29 am »
IIRC, titlebar (with its systemmenu, caption and buttons) is "painted" by the OS, applying themes and what not.

That said: Probably best bet is custom drawn.

No idea how to do it. Never needed it, never will need it
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

paweld

  • Hero Member
  • *****
  • Posts: 1598
Best regards / Pozdrawiam
paweld

RobA

  • New Member
  • *
  • Posts: 19
Re: how to utilize customize form caption row
« Reply #3 on: September 04, 2024, 02:33:18 pm »
On Windows you might want to look at WM_NCPAINT. As I recall, handling that message should let you draw in the title bar, but I'm afraid I can't remember how, or exactly what you are able to do - it's been a long, long time since I needed it.

domasz

  • Hero Member
  • *****
  • Posts: 627
Re: how to utilize customize form caption row
« Reply #4 on: September 04, 2024, 06:38:44 pm »
You can do BorderStyle := bsNone, put a TPanel on your Form, set it to Align := alTop and make it look and work like a real Titlebar.

kirchfritz

  • Jr. Member
  • **
  • Posts: 71
  • WIN11 LAZ 2.2.4 FPC 3.2.2
Re: how to utilize customize form caption row
« Reply #5 on: September 05, 2024, 12:59:11 pm »
You can do BorderStyle := bsNone, put a TPanel on your Form, set it to Align := alTop and make it look and work like a real Titlebar.

You are absolute right. Drawing your own titlebar is possible.
Minimizing, Maximizing, Restoring, Moving form with mouse . All of this is possible.

But......
setting Borderstyle := bsNone causes to much trouble.
You are loosing all possibilities to resize the form.
If you can live without formresizing, everything is quite ok.
If you cant ................. My experience is: Up to now there is (if any) no easy and at the same time satisfying solution

jamie

  • Hero Member
  • *****
  • Posts: 7667
Re: how to utilize customize form caption row
« Reply #6 on: September 05, 2024, 01:14:26 pm »
You can do BorderStyle := bsNone, put a TPanel on your Form, set it to Align := alTop and make it look and work like a real Titlebar.

You are absolute right. Drawing your own titlebar is possible.
Minimizing, Maximizing, Restoring, Moving form with mouse . All of this is possible.

But......
setting Borderstyle := bsNone causes to much trouble.
You are loosing all possibilities to resize the form.
If you can live without formresizing, everything is quite ok.
If you cant ................. My experience is: Up to now there is (if any) no easy and at the same time satisfying solution

Putting a panel as the title bar in a blank form works well for me.

you need to use the Client align or anchors for the panel to keep it attached to the top of the frame and sized properly.

I have several forms like that employing their own title bar with fancy icons on them etc.
The only true wisdom is knowing you know nothing

Packs

  • Sr. Member
  • ****
  • Posts: 496
Re: how to utilize customize form caption row
« Reply #7 on: September 05, 2024, 01:21:23 pm »
Thank you

domasz

  • Hero Member
  • *****
  • Posts: 627
Re: how to utilize customize form caption row
« Reply #8 on: September 05, 2024, 01:40:58 pm »

setting Borderstyle := bsNone causes to much trouble.

Not on Windows. Moving the form:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   ReleaseCapture;
  5.   SendMessage(Form1.Handle, WM_SYSCOMMAND, $F012, 0);
  6. end;

  F012 - move
  F030 - maximize
  F000 - resize
  F020 - minimize
  F060 - close 

jamie

  • Hero Member
  • *****
  • Posts: 7667
Re: how to utilize customize form caption row
« Reply #9 on: September 05, 2024, 01:52:26 pm »
You don't even have to do that.

You can record the mouse down position, then in mouse move event, check if the mouse is still down and then repositioning the form works well, you simply give new form boundsrect values matched with the mouse direction move.

etc.
The only true wisdom is knowing you know nothing

kirchfritz

  • Jr. Member
  • **
  • Posts: 71
  • WIN11 LAZ 2.2.4 FPC 3.2.2
Re: how to utilize customize form caption row
« Reply #10 on: September 05, 2024, 01:59:10 pm »

setting Borderstyle := bsNone causes to much trouble.

Not on Windows. Moving the form:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   ReleaseCapture;
  5.   SendMessage(Form1.Handle, WM_SYSCOMMAND, $F012, 0);
  6. end;

  F012 - move
  F030 - maximize
  F000 - resize
  F020 - minimize
  F060 - close

your code snippet is good for moving the form by mouseclick into the titlebar.
Can you show source code for resizing the form?

kirchfritz

  • Jr. Member
  • **
  • Posts: 71
  • WIN11 LAZ 2.2.4 FPC 3.2.2
Re: how to utilize customize form caption row
« Reply #11 on: September 05, 2024, 02:08:55 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   ReleaseCapture;
  5.   SendMessage(Form1.Handle, WM_SYSCOMMAND, $F000, 0);
  6. end;  

This code changes the cursor but doesnt resize the form.

kirchfritz

  • Jr. Member
  • **
  • Posts: 71
  • WIN11 LAZ 2.2.4 FPC 3.2.2
Re: how to utilize customize form caption row
« Reply #12 on: September 05, 2024, 02:16:40 pm »
by the way: Look at the Adobe Acrobat Reader caption and you will understand the authors wish to create this kind of captionbars!
See picture in attachment


domasz

  • Hero Member
  • *****
  • Posts: 627
Re: how to utilize customize form caption row
« Reply #13 on: September 05, 2024, 02:34:58 pm »
This code changes the cursor but doesnt resize the form.

Try:

Code: Pascal  [Select][+][-]
  1.   SendMessage(Form1.Handle, WM_SYSCOMMAND, SC_SIZE + WMSZ_BOTTOMRIGHT, 0);

jamie

  • Hero Member
  • *****
  • Posts: 7667
Re: how to utilize customize form caption row
« Reply #14 on: September 05, 2024, 06:18:30 pm »
by the way: Look at the Adobe Acrobat Reader caption and you will understand the authors wish to create this kind of captionbars!
See picture in attachment

For your knowledge, look here

https://learn.microsoft.com/en-us/windows/win32/menurc/wm-syscommand
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018