Recent

Author Topic: [SOLVED] Resizable Form - NO Caption - Thin Border  (Read 11545 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1260
[SOLVED] Resizable Form - NO Caption - Thin Border
« on: September 01, 2016, 04:29:34 pm »
I want to make a toolwindow that will always be on top.
This toolwindow will actually be a roll-up type window.
I will be using buttons for rolling up/down, minimizing and exit.

However, I don't want the thick Caption Bar, but I still want the border to be re-sizable.
And I would like the border to be thin, not thick (Windows 7)

I set the Border to none, and that removes the caption bar, but it also doesn't allow me to resize the border.
I set the border to 1 and that doesn't effect the border width (it's like it is still the default 0)

So, how do I hide the Caption bar but keep the border resizing?

So, I am just wondering if their are Design time settings for this or do I have to use code api's etc etc
« Last Edit: September 02, 2016, 01:50:50 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: Resizable Form - But NO Caption Bar on Window
« Reply #1 on: September 01, 2016, 07:10:55 pm »
Well, I couldn't see any design-time... so API it is!!

THIS HIDES THE CAPTION TITLE BAR
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2.  
  3.  
  4. // HIDE CAPTION BAR
  5.   var
  6.   Style: Longint;
  7. begin
  8.   if BorderStyle = bsNone then Exit;
  9.   Style := GetWindowLong(Handle, GWL_STYLE);
  10.   if (Style and WS_CAPTION) = WS_CAPTION then
  11.   begin
  12.     case BorderStyle of
  13.       bsSingle,
  14.       bsSizeable: SetWindowLong(Handle, GWL_STYLE, Style and
  15.           (not (WS_CAPTION)) or WS_BORDER);
  16.       bsDialog: SetWindowLong(Handle, GWL_STYLE, Style and
  17.           (not (WS_CAPTION)) or DS_MODALFRAME or WS_DLGFRAME);
  18.     end;
  19.     Height := Height - GetSystemMetrics(SM_CYCAPTION);
  20.     Refresh;
  21.   end;
  22.  
  23. end;
  24.  

Now... I will try to figure out how to adjust the window border size...

UPDATE: This works to hide the caption and use the default resizing border.
BUT DOESN'T Work properly if you use it on a rollup form.
So, this code is not in the example ZIP file below.
« Last Edit: September 02, 2016, 03:02:58 pm by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: Resizable Form - NO Caption - Thin Border
« Reply #2 on: September 02, 2016, 12:11:44 am »
Well... the above works fine, but when I implemented the rollup functions.
I discovered some issue....

1) I have to be able to disable the Border resizing when the window is rolled up.

2) Just turning BorderStyle to single works, but when I roll the window down, the Caption bar reappears.
So, I recall the the code that hides the caption (and leaves the border), but it doesn't work properly.
So, I have disabled that code for now.

3) Below is screen of window I am making... Rollup works great!!!
However, because I have the BorderStyle set to none, I don't have a border to resize the window when it's rolled down.

4) I have to be able to lock or unlock the border resizing each time the rollup goes up or down.

I am searching everywhere on this way of doing it, but, nothing yet.

Any ideas where I can go from here?
« Last Edit: September 02, 2016, 01:45:15 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: Resizable Form - NO Caption - Thin Border
« Reply #3 on: September 02, 2016, 01:50:34 am »
Okay....

I found some Window Process code by GemMem
http://forum.lazarus.freepascal.org/index.php/topic,33844.msg220327.html#msg220327

That work perfectly... actually the only code I could find that actually worked

So, I have this Roll up form that has no Caption and border set to none.
I just put an Panel on for the border and added a Minimize, Roll-Up/Down buttons and Exit.

The only issues...

1) I would like to know how to keep the border from being resized when the window is "rolled up"
2) Why there is no animation when the app is minimized.

ScreenSHOT & Download on next post below....
« Last Edit: September 02, 2016, 02:58:45 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #4 on: September 02, 2016, 02:54:33 am »
Here is the source code
And Screenshot.

1) You can roll up/down window
2) Double-Click on caption bar to roll up/down
3) Rollup state changes when form is mannually resized to min height or visa-versa
4) Uses panel for "fake" border
5) Simple drag-drop to move form (using just caption bar)
6) Minimize & Exit buttons

« Last Edit: September 02, 2016, 03:08:19 am by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

balazsszekely

  • Guest
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #5 on: September 02, 2016, 11:00:50 am »
@technipixel
Quote
1) I would like to know how to keep the border from being resized when the window is "rolled up"
Code: Pascal  [Select][+][-]
  1. function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam): LRESULT; stdcall;
  2. const
  3.   Margin = 5;
  4. var
  5.   Rect: TRect;
  6.   MouseX, MouseY: LongInt;
  7. begin
  8.   if uMsg = WM_NCHITTEST then
  9.   begin
  10.     if Rollup then Exit; //add this line
  11.     //...
  12.   end;
  13. end;
« Last Edit: September 02, 2016, 11:28:52 am by GetMem »

pixelink

  • Hero Member
  • *****
  • Posts: 1260
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #6 on: September 02, 2016, 11:54:31 am »
@technipixel
Quote
1) I would like to know how to keep the border from being resized when the window is "rolled up"
Code: Pascal  [Select][+][-]
  1. function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam): LRESULT; stdcall;
  2. const
  3.   Margin = 5;
  4. var
  5.   Rect: TRect;
  6.   MouseX, MouseY: LongInt;
  7. begin
  8.   if uMsg = WM_NCHITTEST then
  9.   begin
  10.     if Rollup then Exit; //add this line
  11.     //...
  12.   end;
  13. end;

GemMem... Thanks for your code for the border resize.
This works great.

I actually didn't try to figure out my question about not resizing when rolled up because... the way I got this rollup to work with Minimize Height actually worked good.
So, a user can resize even when rolled up.

Your fix adding "if Rollup then Exit; " was way to easy. I am sure I would figured that out if I had tried.
Now, I have both options!!

This LAZ version of the rollup works much better than the one I made in VB6.

Again... THANKS!
:)


Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

Akira1364

  • Hero Member
  • *****
  • Posts: 563
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #7 on: September 04, 2016, 07:44:40 am »
Thanks to "GemMem", indeed...  :P

In fact it is a neat bit of code, though.

folkeu08

  • Full Member
  • ***
  • Posts: 114
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #8 on: November 01, 2022, 01:58:40 pm »
Here is the source code
And Screenshot.

1) You can roll up/down window
2) Double-Click on caption bar to roll up/down
3) Rollup state changes when form is mannually resized to min height or visa-versa
4) Uses panel for "fake" border
5) Simple drag-drop to move form (using just caption bar)
6) Minimize & Exit buttons

Hi,
I'm interesting by this rollUp and Down Panel.
I've try the code and the function RollDown is not OK under Lazarus 2.2.4.
Someone can modifie the code ?
Thanks
Fanch

balazsszekely

  • Guest
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #9 on: November 01, 2022, 03:50:15 pm »
Hi folkeu08,

Quote
I'm interesting by this rollUp and Down Panel.
I've try the code and the function RollDown is not OK under Lazarus 2.2.4.
Someone can modifie the code ?
Thanks
I cannot test now(l' m not home), but what do you mean by "not OK"? You cannot compile it, It's not working as it should? Can you please be more specific?


PS: Working fine here. Please note that the above code (@pixelink's test project) is windows only. You will be unable to compile it on other platforms.
« Last Edit: November 01, 2022, 05:10:36 pm by GetMem »

folkeu08

  • Full Member
  • ***
  • Posts: 114
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #10 on: November 01, 2022, 05:20:19 pm »
Hi GetMem,

I compile it but at the start of application the panel is good extand.
I click on the up arrow, the panel goes up.
The arrow changes direction down and if I click on it, the panel does not expand to its original size.
I have not found an equivalent elsewhere that suits me.
I have a form with little height to place 2 DBgrid (1 master and 1 detail).
The idea is to use 2 rollof panels to display each grid with maximum height.
It's a bit of a splitter principle but I find the graphic effect more pleasant with your solution.
Folkeu08

balazsszekely

  • Guest
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #11 on: November 01, 2022, 07:11:35 pm »
@folkeu08

Can you attach a small demo application where the issue is clearly reproducible? You don't have to link the grids to a datasource.

folkeu08

  • Full Member
  • ***
  • Posts: 114
Re: [SOLVED] Resizable Form - NO Caption - Thin Border
« Reply #12 on: November 01, 2022, 07:50:42 pm »
Hi GetMem,

I have not yet inserted your rollup panel in my form.
I just tried your source in the post Reply #4 on: September 02, 2016, 02:54:33 am from the topic.
Fokeu08

 

TinyPortal © 2005-2018