Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Minimise a form but not the App??


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Nov 14, 2015 1:40 PM Last Post By: Tom Brunberg
Ian Branch

Posts: 442
Registered: 9/23/99
Minimise a form but not the App??  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 12, 2015 3:12 PM
Hi Guys,
Delphi 10 Seattle..
I have two forms, the first calls the second.
When I call the second I want to minimize the firs but keep the second on the screen.
Then when I close the second, restore the first.
Can't use Application.minimize as that minimizes everything.

Suggestions appreciated.

Regards & TIA,
Ian
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Minimise a form but not the App??  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 12, 2015 3:34 PM   in response to: Ian Branch in response to: Ian Branch
Ian wrote:

I have two forms, the first calls the second.
When I call the second I want to minimize the firs but keep the second
on the screen.
Then when I close the second, restore the first.

By default, the Application.MainFormOnTaskbar property is true, which means
the MainForm will manage the app's Taskbar button on Vista+ (amongst other
things) instead of the TApplication object managing it. As such, minimizing
the MainForm will minimize the entire app.

--
Remy Lebeau (TeamB)
Tom Brunberg

Posts: 329
Registered: 12/27/04
Re: Minimise a form but not the App??  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 13, 2015 2:16 PM   in response to: Ian Branch in response to: Ian Branch
Ian Branch wrote:

Hi Guys,
Delphi 10 Seattle..
I have two forms, the first calls the second.
When I call the second I want to minimize the firs but keep the second on the screen.
Then when I close the second, restore the first.
Can't use Application.minimize as that minimizes everything.

Suggestions appreciated.

Regards & TIA,
Ian

Ian,
There are two ways (at least):
1. Hide Form1 in Form2.FormShow() (Form2 OnShow) and Show Form1 in Form2.FormHide.
IOW, in Form2
implementation
 
{$R *.dfm}
uses Unit1;
 
procedure TForm2.FormHide(Sender: TObject);
begin
  Form1.Show;
end;
 
procedure TForm2.FormShow(Sender: TObject);
begin
  Form1.Hide;
end;

2. In Form1, hide Form1, ShowModal Form2 and show Form1 on return from Form2:
implementation
 
{$R *.dfm}
uses Unit2;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
  self.Hide;
  Form16.ShowModal;
  self.Show;
end;


--
Tom Brunberg
firstname.lastname@welho.com

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Minimise a form but not the App??  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 13, 2015 3:16 PM   in response to: Tom Brunberg in response to: Tom Brunberg
Tom wrote:

There are two ways (at least):

Both have the side effect that the app's Taskbar button will be hidden when
Application.MainFormOnTaskbar is true.

--
Remy Lebeau (TeamB)
Ian Branch

Posts: 442
Registered: 9/23/99
Re: Minimise a form but not the App??  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2015 10:32 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi Team et Al,
I ended up using the Form1.Visible property.
Meets most of my needs...:-)
Thank you all for your input/suggestions.
Regards,
Ian
Tom Brunberg

Posts: 329
Registered: 12/27/04
Re: Minimise a form but not the App??  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2015 1:40 PM   in response to: Ian Branch in response to: Ian Branch
Ian Branch wrote:

I ended up using the Form1.Visible property.

Ian,
... which is almost ;-) the same as 'Hide' and 'Show'
procedure TCustomForm.Hide;
begin
  Visible := False;
end;
 
procedure TCustomForm.Show;
begin
  Visible := True;
  BringToFront;
end;


--
Tom Brunberg
firstname.lastname@welho.com
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02