面向过程的命令模式
{*******************************************************}
{ }
{ 命令模式的简化 }
{ }
{ 版权所有 (C) 2008 陈新光 }
{ }
{*******************************************************}
...
type
TFormHycx = class(TFormMdi)
private
procedure MenuItemClick(sender:TObject);
end;
...
procedure TFormHycx.FormCreate(Sender: TObject);
var
i:Integer;
begin
inherited;
for i:=0 to PopupMenu.Items.Count-1 do
PopupMenu.Items[i].OnClick:=MenuItemClick;
end;
...
procedure TFormHycx.MenuItemClick(sender: TObject);
begin
case TMenuItem(sender).Tag of
100:ShowGridColEditorA(TDBGridEh(ActiveControl));
101:FindPublicShowA(TDBGridEh(ActiveControl).DataSource.DataSet);
102:ShowFilterFormA(TDBGridEh(ActiveControl).DataSource.DataSet);
103:ShowGroupA(TDBGridEh(ActiveControl));
104:ExpDbgridEhA(TDBGridEh(ActiveControl));
105:PrntA(TDBGridEh(ActiveControl),self);
end;
end;
{ }
{ 命令模式的简化 }
{ }
{ 版权所有 (C) 2008 陈新光 }
{ }
{*******************************************************}
...
type
TFormHycx = class(TFormMdi)
private
procedure MenuItemClick(sender:TObject);
end;
...
procedure TFormHycx.FormCreate(Sender: TObject);
var
i:Integer;
begin
inherited;
for i:=0 to PopupMenu.Items.Count-1 do
PopupMenu.Items[i].OnClick:=MenuItemClick;
end;
...
procedure TFormHycx.MenuItemClick(sender: TObject);
begin
case TMenuItem(sender).Tag of
100:ShowGridColEditorA(TDBGridEh(ActiveControl));
101:FindPublicShowA(TDBGridEh(ActiveControl).DataSource.DataSet);
102:ShowFilterFormA(TDBGridEh(ActiveControl).DataSource.DataSet);
103:ShowGroupA(TDBGridEh(ActiveControl));
104:ExpDbgridEhA(TDBGridEh(ActiveControl));
105:PrntA(TDBGridEh(ActiveControl),self);
end;
end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/archive/2008/03/14/2941059.html