如果有规律性就用个fordo
搞定
我的一个系统是这的所有form都是通过一个事件完成的
procedure Tfm_MDI.Action1Execute(Sender: TObject);
var
i,
iTag: integer;
sCap: String;
F: TForm;
fa: TFormClass;
// className
begin
if CheckMDIChilds(Sender,fm_MDI,pageControl1,PopupMenu) then
Exit;
//检查MDIChilds是否存在
Fa := nil;
iTag := (sender as TAction).Tag;
sCap := (sender as TAction).Caption;
case iTag of
2: Fa := Tfm_Edwk;
// 收发记录录入
3: Fa := Tfm_Brwk;
// 收发记录修改
4: Fa := Tfm_EdCoding;
// 工序录入
5: Fa := Tfm_GmPlan;
// 工模申请单录入
6: Fa := Tfm_BrGmBase;
// 工模业绩日报录入
7: Fa := Tfm_wktj;
// 工作单工时成本
8: Fa := Tfm_wktime;
// 员工作业时间统计 //报表
9: Fa := Tfm_CodPrn;
//工序编号对应报表 //报表
10: Fa := Tfm_GmBasePrn;
// 工模房个人业绩报表 //报表
11: Fa := Tfm_BrPrcAvg;
// 计价单价(工作单)
12: Fa := Tfm_BrPrcCd;
// 计件单价(型 号/工序)
13: Fa := Tfm_PieceOfWkno;
// 按单计件统计 2004-8-11 //报表
14: Fa := Tfm_PieceOfMon;
// 按(工序)计件统计 时间段(工序)计件统计 //报表
15: Fa := Tfm_PvgOfMon;
// 按(技术分)计件统计 月(技术分)计件统计 //报表
16: Fa := Tfm_BrbktFrm;
// 浏览内部退货 2004-8-13}
28: Fa := Tfm_WKbrowse;
// 浏览工作单数量
17: Fa := Tfm_Brwaste;
// 损耗申请 2004-8-17
18: Fa := Tfm_BrwastePrc;
// 物料损耗单价 2004-8-19
19: Fa := Tfm_wasteadi;
// 损耗申请清单 2004-8-20 //报表
20: Fa := Tfm_wasteprc;
// 损耗单价清单 2004-8-21 //报表
21: Fa := Tfm_wasteMoneyof;
// 耗扣款/材料节省报表(汇总) //报表 2004-8-21
//22: Fa := Tfm_wasteMoneyof;
// 损坏扣款/节省奖励报表(明细) 2004-8-22
1 : close;
// 退出
23: Tfm_sysHelp.CreateHelpSysForm(ProcdSys);
// 帮助
22: UpdateSoftWare;
24: EV.MsgBox(UserInfo.About, MB_OK);
25: if MDIChildCount <>
0 then
ActiveMDIChild.Close;
//关闭活动MDIChild
26,
27: begin
// 是否显示工具栏
(sender as TAction).Checked := not (sender as TAction).Checked;
case iTag of
26: ToolBar1.Visible := (sender as TAction).Checked;
27: PageControl1.Visible := (sender as TAction).Checked;
end;
end;
else
showmessage('还没有完成'+sCap);
end;
try
StatusBar1.Panels[StatusBar1.tag].Text := '请稍候正在执行查询......';
Screen.Cursor := crSQLWait;
StatusBar1.Update;
Application.ProcessMessages;
if (Fa <>
nil) then
begin
F := FindShowForm(fa);
if F = nil then
exit;
F.Tag := iTag;
F.Caption := sCap;
F.FormStyle := fsMDIChild;
F.OnClose := FormClose;
if F.BorderIcons = [biSystemMenu,biMinimize,biMaximize] then
F.WindowState := wsMaximized;
Action25.Enabled := (MDIChildCount <>
0);
MenuItem1.Enabled := (MDIChildCount <>
0);
SetDataSourceChange(F);
for i := F.ComponentCount-1do
wnto 0do
begin
if F.Components is TSplitter then
TSplitter(F.Components).OnMoved := Splitter1Moved;
if F.Components is TDBGrid then
begin
TDBGrid(F.Components).OnTitleClick := DBGridTitleClick;
end;
end;
CreatePages(F, PageControl1, PopupMenu, PopupMenuclikClick);
//XPMenu2.ActivateMenuItem(PopupMenu.Items,true);
end;
finally
StatusBar1.Panels[StatusBar1.tag].Text := '查询已完成!';
Screen.Cursor := crDefault;
end;
end;
// 检查窗体是否存在,Nil则创建
function InternalFindShowForm(FormClass: TFormClass;
Restore: Boolean): TForm;
var
I: Integer;
begin
Result := nil;
for I := 0 to Screen.FormCount - 1do
begin
if Screen.Forms.ClassNameIs(FormClass.ClassName) then
Result := Screen.Forms;
Break;
end;
if Result = nil then
Application.CreateForm(FormClass, Result);
// with Resultdo
begin
// if Restore and (WindowState = wsMinimized) then
WindowState := wsNormal;
// Show;
// end;
end;
// 调用检查Forms
function FindShowForm(FormClass: TFormClass): TForm;
begin
Result := InternalFindShowForm(FormClass, True);
end;