displaying windows

  • Thread starter Thread starter Piotrek Stachowicz
  • Start date Start date
P

Piotrek Stachowicz

Hi,
My application has 3 windows, each of them is separate form. One of
them (called MainWindow) is visible in task bar, others are not. I'd like
them to behave in the following:

1) when main window gets focus (or is "restored"), others should be brought
to the front
2) when main window is minimized, others should also be minimized (hidden?)

I thought about handling "Activated" event in MainWindow, but I don't really
have any idea what to do next.

Thanks

Piotrek Stachowicz
 
Put a reference to each window into the main Form.

somewhere in your main form class you put
(ugly stuff)

public yourWin2Class window2;
public yourWin3Class window3;

in the main form on load you do:

window2 = new yourWin2Class();
window3 = new yourWin3Class();

//Put here the initialization from your last request ;-)

window2.Show();
window3.Show();

in the resize function of the main window you do:

window2.WindowState = this.WindowState;
window3.WindowState = this.WindowState;

// And again:
//Put here the initialization from your last request ;-)

This should do it. But you should check for the WindowState == Maximized
stuff and react on this, otherwise you will get funny behaviour(I guess)

Have fun,

Martin
 
It seems like what you want to do is make the secondary forms owned by the
main form.

ChildForm1.Owner = MainForm;
ChildForm2.Owner = MainForm;

When a form is owned by another it is activated and minimized with its
owner. In addition, owned forms are never displayed behind their owner.

Hope this helps.
- Rhy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top