I want to get the previous active control in Delphi, i have tried to used OnActiveControlChange event, but even through that i can get the current active control not the previous one.
Thanks for the help in advance. --Vijay
Try this Code
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;
Use wcControl.Name
to get the name of previous control
For more information go through this link
You could build yourself a 'history' of active controls using this event, and to find the previous you would consult your history list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With