以下是MDI软件中典型的做法,反正我是这么实现的:
procedure TMainForm.ChwiseMainExecute(Sender: TObject);
begin
case (Sender as TComponent).Tag of
1:begin
if FormXcmzin=nil then Application.CreateForm(TFormXcmzin, FormXcmzin);
FormXcmzin.BringToFront;
end;
2:begin
if FormCustomerin=nil then Application.CreateForm(TFormCustomerin, FormCustomerin);
FormCustomerin.BringToFront;
end;
3:begin
if FormProject1in=nil then Application.CreateForm(TFormProject1in, FormProject1in);
FormProject1in.BringToFront;
end;
4:begin
if FormProduct1in=nil then Application.CreateForm(TFormProduct1in, FormProduct1in);
FormProduct1in.BringToFront;
end;
5:begin
if FormWindowDef1in=nil then Application.CreateForm(TFormWindowDef1in, FormWindowDef1in);
FormWindowDef1in.BringToFront;
end;
else
MessageBox(MainForm.Handle,'对不起, 还没有提供该操作!','提示',MB_OK or MB_ICONINFORMATION);
end;
end;