如何找到以前的主动控件:Delphi

Vij*_*bba 6 delphi

我想在Delphi中获得以前的主动控件,我试图使用OnActiveControlChange事件,但即使通过我可以得到当前的主动控件而不是前一个.

我在这里先向您的帮助表示感谢.--Vijay

Bha*_*rat 9

试试这个代码

  TForm1 = class(TForm)
  ---
  --- 
  private
    { Private declarations }
    wcActive, wcPrevious : TWinControl;
  public
    { Public declarations }
    procedure ActiveControlChanged(Sender: TObject) ;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ActiveControlChanged(Sender: TObject);
begin
  wcPrevious := wcActive;
  wcActive := Form1.ActiveControl;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.OnActiveControlChange := ActiveControlChanged;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Screen.OnActiveControlChange := nil;
end;
Run Code Online (Sandbox Code Playgroud)

使用wcControl.Name得到控制以前的名字

有关更多信息,请浏览此链接


Dar*_*ler 5

您可以使用此事件为自己构建活动控件的"历史记录",并查找之前的内容,您将查看历史记录列表.