先定义
bool OpenForm( TForm * WForm )
{
int i;
bool FormExist;
if( WForm == NULL )
return false;
FormExist = false;
for( i=0;i<Screen->FormCount;
i++ )
{
if( Screen->Forms->ClassType() == WForm->ClassType())
{
FormExist = true;
break;
}
}
return FormExist;
}
//------------------------------------------------------------------------------
try
{
if(OpenForm(Form1) == false)
{
Form1=new TForm1(Application);
}
else
{
if( Form1->WindowState == wsMinimized )
ShowWindow(Form1->Handle,SW_SHOWNORMAL);
else
ShowWindow(Form1->Handle,SW_SHOWNA);
Form1->BringToFront();
Form1->SetFocus();
}
}
catch (Exception &exception)
{
Application->ShowException(&exception);
return;
}