Recent

Author Topic: resize Form when enable or disable control...  (Read 742 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
resize Form when enable or disable control...
« on: May 27, 2022, 01:43:31 am »
Hi how i can resize form if enable or disable and visible or not visible at form image is all controls enabled and visible and 2 image you can see i disable and not visible the panel, and 3 image you can see is showing form with free space where must be going panel...

What i need is change form and adjust to the controls like change height of form....


zoltanleo

  • Sr. Member
  • ****
  • Posts: 408
Re: resize Form when enable or disable control...
« Reply #1 on: May 27, 2022, 06:21:26 am »
Hi eldonfsr

Code: Pascal  [Select][+][-]
  1. procedure TForm1.CheckBox1Change(Sender: TObject);
  2. begin
  3.   Panel2.Visible:= CheckBox1.Checked;
  4.   Self.Repaint;
  5. end;
  6.  
  7. procedure TForm1.FormCreate(Sender: TObject);
  8. begin
  9.   Panel1.Color:= clMoneyGreen;
  10.   Panel1.Constraints.MinWidth:= 300;
  11.   Panel1.Caption:= '';
  12.   Panel2.Color:= clCream;
  13.   Self.AutoSize:= True;
  14.   CheckBox1.Checked:= True;
  15.   CheckBox1Change(Self);
  16. end;

https://i.imgur.com/0ltI6PM.gif

Upd: But I am of the opinion that the size of the form should not change. It's better to resize adjacent controls.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3. ...
  4.   //Self.AutoSize:= True;
  5. ...
  6. end;

https://i.imgur.com/WRztmkV.mp4
« Last Edit: May 27, 2022, 06:42:14 am by zoltanleo »
Win10 LTSC x64/Deb 11 amd64/Darwin Cocoa (Monterey):
Lazarus x32/x64 2.3(trunk); FPC 3.3.1 (trunk), FireBird 3.0.7

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

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
Re: resize Form when enable or disable control...
« Reply #2 on: May 27, 2022, 04:40:56 pm »
Thanks for your replay, well after some test is working  but as must be....
why
first thing is i don't know you can see image 1 las panel is no show as is only half if that is showing...happen if its align to bottom too.....

but you check on second when panel i align to client is show complete but bigger that it is size is 35 height you can see previous post at image 1 is mast be look...

procedure TFormMain.FormCreate(Sender: TObject);
begin
  If Not DirectoryExists(GetUserDir +'AppData\Local\Sbackup') then begin
       If Not CreateDir (GetUserDir +'AppData\Local\Sbackup') Then
          Showmessage('Can create a folder for save backup files configuration');;
    end;
    FormMain.Top:=10;
    FormMain.Left:=10;
    FormMain.Panel5.Height:=35;
    FormMain.StatusBar1.Panels[0].Width:= FormMain.StatusBar1.Width div 2;
    Self.AutoSize:= True;
end;   
 

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
Re: resize Form when enable or disable control...
« Reply #3 on: May 27, 2022, 08:14:32 pm »
I made a test apps you can see if you change align of panel five top, bottom and client how is show in different view...

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
Re: resize Form when enable or disable control...
« Reply #4 on: May 27, 2022, 08:35:47 pm »
Big question why if form has statusbar affect view of form, If delete status bar all controls is show as must be but if form has status bar cut at bottom if form some part and affect control near to status bar....

I never put attention on that .....

some idea of that how to fix.....

Thaddy

  • Hero Member
  • *****
  • Posts: 11623
Re: resize Form when enable or disable control...
« Reply #5 on: May 28, 2022, 10:15:03 am »
The form needs to be able to receive messages, which is not possible if it is disabled. The resize messages are no exception!
Black themes should be banned.

zoltanleo

  • Sr. Member
  • ****
  • Posts: 408
Re: resize Form when enable or disable control...
« Reply #6 on: May 30, 2022, 08:40:31 pm »
Big question why if form has statusbar affect view of form, If delete status bar all controls is show as must be but if form has status bar cut at bottom if form some part and affect control near to status bar....

I never put attention on that .....

some idea of that how to fix.....

In your case, I didn't find any problem with resizing the form. You just need to make the correct anchoring of the controls on the form (you need to anchor statusbar to bottom edge of the form, panel5 to the statusbar, and panel8 to panel5). I even removed the Self.Repant method because it works anyway.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.CBShowPChange(Sender: TObject);
  2. begin
  3.   Panel8.visible:= CbShowP.Checked;
  4. end;
  5.  
  6. procedure TForm1.FormCreate(Sender: TObject);
  7. begin
  8.   with Panel8 do
  9.   begin
  10.     Constraints.MinHeight:= ProgressBar1.Height
  11.                         + BorderSpacing.Bottom
  12.                         + BorderSpacing.Top;
  13.     Constraints.MaxHeight:= Constraints.MinHeight;
  14.   end;
  15.  
  16.   with Panel5 do
  17.   begin
  18.     Constraints.MinHeight:= BtnStart.Height
  19.                             + BtnStart.BorderSpacing.Top
  20.                             + BtnStart.BorderSpacing.Bottom;
  21.     Constraints.MaxHeight:= Constraints.MinHeight;
  22.   end;
  23.   Self.AutoSize:= True;
  24.   CBShowPChange(Sender);
  25. end;
                             
« Last Edit: May 30, 2022, 08:52:26 pm by zoltanleo »
Win10 LTSC x64/Deb 11 amd64/Darwin Cocoa (Monterey):
Lazarus x32/x64 2.3(trunk); FPC 3.3.1 (trunk), FireBird 3.0.7

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

eldonfsr

  • Sr. Member
  • ****
  • Posts: 295
Re: resize Form when enable or disable control...
« Reply #7 on: June 03, 2022, 03:38:51 pm »
Yes but if you change status bar align bottom you will see affect panel5 it is now showing complete...

thanks... is great help i learned  other way to implements those things.


thanks...

 

TinyPortal © 2005-2018