⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 motherview.pas

📁 Delphi利用MVC开发的典型例子
💻 PAS
字号:
unit MotherView;

// This code was generated by the EasyMVC OTA Wizard
// www.eazisoft.com

interface
uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, StdCtrls, ComCtrls, ExtCtrls, Forms, patterns;

type
  TViewMother = class(TFRAME, IObserver)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Memo1: TMemo;
    ComboBox1: TComboBox;
    Timer1: TTimer;
    Label5: TLabel;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    procedure UpdateView(o: TObject); //from IObserver
  public
    { Public declarations }
    function getCommand: string;
    procedure setEventHandler(ANotifyEvent: TNotifyEVent; const AMouseEvent: TMouseEvent = nil);
  end;


implementation
uses
  commandlist, indexdef;
{$R *.dfm}

function TViewMother.getCommand: string;
begin
  result := ComboBox1.Text;
end;

procedure TViewMother.setEventHandler(ANotifyEvent: TNotifyEVent; const AMouseEvent: TMouseEvent = nil);
begin
  Button1.OnClick := ANotifyEvent;
end;

procedure TViewMother.UpdateView(o: TObject);
var
  p: PResponseInfo;
begin
  {write your code here}
    {write your code here}
  if not assigned(o) and not (o is TCommand) then
    exit;

  p := (o as TCommand).getParamrecord;
  if assigned(p) then
  begin
    Edit1.Text := p.CMD;
    Edit2.Text := p.Response;
    Memo1.Lines.Text := p.ActualMean;
    timer1.Enabled := (p.CMD = CMD_NODE_SELECT);
    if p.CMD = CMD_CLEAR_SELECTION then
      Edit2.Color := clWindow;
  end;

  update;
  freeAndNil(o);
end;

procedure TViewMother.Timer1Timer(Sender: TObject);
begin
  if Edit2.Color = clWindow then
    Edit2.Color := clRed
  else
    Edit2.Color := clWindow;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -