看下面的程序.关键是1,2处.现在的情况程序运行正常,如果我将1,2处交换,程序运行完后,this(父窗体)最小化了.为什么?请教达人 frmNotice objMsg = new frmNotice();
objMsg.ShowMessage = "正在生成项目树,请稍候……";
objMsg.Show(this);
this.Enabled = false;
string strPrjId = Program.gsPrjID;
if (strPrjId != "")
{
try
{
Application.DoEvents();
CProject.GenerateProjectTree(strPrjId, tvProject);
}
catch (Exception err)
{
CComFun.ShowMessageBox(this, err.Message);
}
}
this.Enabled = true;//-------------1
objMsg.Close(); //-----------------2
objMsg.ShowMessage = "正在生成项目树,请稍候……";
objMsg.Show(this);
this.Enabled = false;
string strPrjId = Program.gsPrjID;
if (strPrjId != "")
{
try
{
Application.DoEvents();
CProject.GenerateProjectTree(strPrjId, tvProject);
}
catch (Exception err)
{
CComFun.ShowMessageBox(this, err.Message);
}
}
this.Enabled = true;//-------------1
objMsg.Close(); //-----------------2
objMsg.Show()后禁用了主窗口,然后如果更换成顺序21的话,相当于在子窗口(objMsg)关闭时主窗口是无效的,在这种情况下会自动最小化主窗口。