Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

How to minimize only main form and not all windows?

Hi,

I have an application with different forms. When I minimize the main form, all other windows are minimized too!!! The other windows are bsToolWindow's, so not normal windows. They have no 'Minimize' button...
Is it possible to minimize ONLY the main window and that the oter bsToolWindow's will stay visible???


thanks
0
Bohne
Asked:
Bohne
  • 8
  • 3
1 Solution
 
lmikleCommented:
for example, you can create yours tool windows with set parent to desktop.

1. Remove your tool windows from autocreate.
2. In OnCreate of main form create those windows using CreateParented contructor:

procedure TForm1.Form1Creare(Sender);
begin
  TW1 := TToolWin1Form.CreateParented(GetDesktopWindow);
  TW2 := TToolWin2Form.CreateParented(GetDesktopWindow);
end;

don't forget to free TW1 and TW2 in OnDestroy event.
0
 
BohneAuthor Commented:
... sounds good! But could you get a bit more specific? What is TW1 and TToolWin1Form? My tool windows are called Form2 and Form3. Is TToolWin1Form=Form2 or where are my forms specified?
And do I have to declare TW1 and TW2? Are these just variables?
And finally could you tell me the command to destroy these two windows?

thank you very much
0
 
lmikleCommented:
Yes.

TToolWin1Form is your Form2 and TToolWin2Form is your Form3.

TW1 and TW2 is the variables to store pointers on those windows. The main form description must looks as:

TForm1=class(TForm)
...
private
  TW1 : TFrom2;
  TW2 : TFrom3;
...
end;

and in this case Oncreate event must be like this:

procedure TForm1.Form1Creare(Sender);
begin
 TW1 := TForm2.CreateParented(GetDesktopWindow);
 TW2 := TForm3.CreateParented(GetDesktopWindow);
end;
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BohneAuthor Commented:
...thanks, it works now! I can create the window, and it does no longer minimize!
BUT it behaves very strang... I can't press any button on this form and I can't move it... Do you know why this is???

And can you tell my how I have to destroy it at the end?
0
 
BohneAuthor Commented:
... it's so strange! Why can't I press any button on this form??? And why can't I move it??? When I try to pic it, it changes from active to inactive all the time...

To destroy it I use TW1.Free; rigth?
0
 
lmikleCommented:
OK.

Example:

In MainForm OnCreate:

NagForm := TNagForm.Create(Nil);
NagForm.ParentWindow := GetDesktopWindow;
NagForm.Show;

Also,

In this example property FormStyle of NagForm has fsStayOnTop value. I have 3 buttons on this NagForm and all of them work properly.

May be you must call a method from MainForm in on click event of any button on your tool window.
0
 
BohneAuthor Commented:
... hm, the creation seems not to be the problem. Because my form behaves exactly the same with the code above! :-(

So where is the problem then? I don't know where to start searching... Perhaps my button method is incorrect when the form is created this way!
Here my onclick event:

procedure TForm3.abortclick(Sender: TObject);
begin
    Form1.abortClick(Sender);
end;

Form3 is my GetDesktopWindow. Form1, the main form, does also have a button called abort with a method abortClick. That's why they have the same name...

Does this not work like this in a GetDesktopWindow? With a normal form it works without any problems...
0
 
BohneAuthor Commented:
WHAT?!?!? Now I found out something reeealy strange!!! When I press the GetDesktopWindow anywhere, but not the button itself. I mean I just click somewhere on the form, ButtonClick is executed!!!
But when I press the button, nothing happens!!! How can this be??????? The procedure ButtonClick is executed when I click on the form!!! :-(
0
 
BohneAuthor Commented:
... sorry, this with the Form click was stupid! But the button is still not working! :-(

I made a small project where the button does not work. Perhaps you can have a look at it:
http://www.n.ethz.ch/student/huberret/project.zip
I included the source and the exe...

thank you
0
 
BohneAuthor Commented:
... sorry, this with the Form click was stupid! But the button is still not working! :-(

I made a small project where the button does not work. Perhaps you can have a look at it:
http://www.n.ethz.ch/student/huberret/project.zip
I included the source and the exe...

thank you
0
 
BohneAuthor Commented:
... sorry, this with the Form click was stupid! But the button is still not working! :-(

I made a small project where the button does not work. Perhaps you can have a look at it:
http://www.n.ethz.ch/student/huberret/project.zip
I included the source and the exe...

thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now