//该函数判断窗体是否存在,如果存在,显示该窗体并返回false,否则返回true
private bool FormNotExist(System.Windows.Forms.Form f)
{
bool flag = true;
if (f == null) return flag;
for (int i = 0; i < this.MdiChildren.Length; i++)
{
if (this.MdiChildren[i].Name == f.Name)
{
flag = false;
if (this.MdiChildren[i].WindowState == FormWindowState.Minimized)
{
this.MdiChildren[i].WindowState = FormWindowState.Normal;
}
if (this.MdiChildren[i].Visible == false)
{
this.MdiChildren[i].Show();
}
this.MdiChildren[i].Activate();
}
}
return flag;
}
//下面是调用该窗体的实例
//声明数据成员
private Form1 form1;
//调用
if (this.FormNotExist(form1))
{
form1 = new Form1();
form1.MdiParent = this;
form1.Show();
}
[此贴子已经被作者于2007-2-23 17:46:05编辑过]