面向过程的命令模式

{*******************************************************}
{                                                       }
{       命令模式的简化                                  }
{                                                       }
{       版权所有 (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;  
posted @ 2008-03-14 12:58  delphi中间件  阅读(241)  评论(0编辑  收藏  举报