Recent

Author Topic: Form.BorderStyle.bsSizeable without the top border ?  (Read 13273 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Form.BorderStyle.bsSizeable without the top border ?
« on: July 15, 2010, 04:13:48 pm »
Hello everybody.
I would like to have a main form sizeable but without the top-tray header (with help,system buttons), like a BorderStyle BsNone.
If i choose BsNone, ok, no top border but i cannot resize the window (no more borders at all) ? 

PS 2 How can i know the height of a top border ?

Thanks
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #1 on: July 15, 2010, 05:08:36 pm »
You can do something like this:

Code: [Select]
var d :boolean=false;
procedure TForm1.FormMouseDown(Sender:TObject;Button:TMouseButton;Shift:
  TShiftState;X,Y:Integer);
begin
  if ((x > width - 10) or (y > height - 10)) then
    d := true;
end;

procedure TForm1.FormMouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);
begin
  if d then
  begin
    height := y;
    width := x;
  end;
end;

procedure TForm1.FormMouseUp(Sender:TObject;Button:TMouseButton;Shift:
  TShiftState;X,Y:Integer);
begin
  d := false;
end;     

So you can resize the window by yourself.
« Last Edit: July 15, 2010, 05:20:20 pm by typo »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #2 on: July 15, 2010, 05:32:17 pm »
If you do that, you should set MouseCapture := True in mouse down, and False in mouse up.

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #3 on: July 15, 2010, 05:49:33 pm »
Thanks, first problem solved.
And how to know the height of the top border of a normal sizeable form ?

OOps, first prob not solved, i get a form without border with bsnone but i cant resize the form (i mean, with the cursor, not allow to resize if i go near the border).
« Last Edit: July 15, 2010, 06:11:18 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #4 on: July 15, 2010, 06:19:30 pm »
The code above allows you to resize the window whenever the mouse is clicked and dragged 10 points from the border.

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #5 on: July 15, 2010, 06:55:19 pm »
Hi typo.
All right but it is not really like a sizeable window without top borders (dont have any borders, no cursor changing shape, etc).
Thanks
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #6 on: July 15, 2010, 07:01:40 pm »
You can add code to improve this. There is no way to get rid of the system bar without doing so with the sizeable feature of the form.

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #7 on: July 21, 2010, 05:09:52 pm »
Hello everybody.
I m still waiting for a answer for
Quote
PS 2 How can i know the height of a top border ?

I want to know the height of the top border of a resizable windows .
Thanks
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1930
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #8 on: July 21, 2010, 06:23:51 pm »
I want to know the height of the top border of a resizable windows .
Thanks

On Windows, you could probably google for GetSystemMetrics.
On Linux, afaik this is not available without extra effort.
It's a window mangager thing. One thing I've learned is:
Don't fiddle with the window manager. ;-)

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #9 on: July 21, 2010, 07:17:47 pm »
Thanks Leo.
The code is for all systems then i think i gonna create my own windows.

Maybe i think to use Mouse.CursorPos.Y  (get the position on the screen)  and compare it with Y given by form.MouseDown();   .

Code: [Select]
procedure Tform1.form1MouseDown(Sender: TObject;
                  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);       
var
heigthtop : integer ;

   begin
Mouse.CursorPos.Y - Y := heigthtop ;
end;


Or something better ?  
Thanks  
« Last Edit: July 21, 2010, 07:49:02 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1930
Re: Form.BorderStyle.bsSizeable without the top border ?
« Reply #10 on: July 21, 2010, 08:28:59 pm »
Or something better ?  

This might work, at least on linux. But it's of course 0 with BorderStyle bsNone.

ClientToScreen(Point(0,0)).Y-Top

 

TinyPortal © 2005-2018