Checking if Windows Form is open?

V

VMI

Through my MDI application, I open a FormX that is opened outside of the
application (not an MDI child). How can I check if the Form's open so I
don't load two instances of the same window? Is it possible that, within the
MDI container, a Form can have TopMost equal to true? For some reason,
TopMost property only works when the window's opened outside the MDI
container.

Thanks.
 
S

ShaneB

Here's one way to accomplish the first part of your question. As to the
second part, I'll leave that to someone else because it's late :)

private FavoritesFrm _FavoritesFrm;
....
private void button1_Click(object sender, System.EventArgs e)
{
if (_FavoritesForm == null)
{
_FavoritesForm = new FavoritesFrm();
_FavoritesForm.Closed += new EventHandler(_FavoritesForm_Closed);
}
_FavoritesForm.WindowState = FormWindowState.Normal; // bring it from
the taskbar if necessary
_FavoritesForm.Show();
}

private void _FavoritesForm_Closed(object sender, EventArgs e)
{
_FavoritesForm = null;
}

HTH,
ShaneB
 

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

Top