2010-12-16 28 views

Respuesta

8

Prueba este Código

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; 

Uso wcControl.Name para obtener el nombre del control anterior

Para más información ir a través de this link

+0

Gracias Bharat I se perdió esta simple lógica –

4

Puede construir un "historial" de controles activos utilizando este evento, y para encontrar el anterior, debería consultar su lista de historial.

+0

Gracias Miller historia manteniendo me ayuda a resolver otro problema –

Cuestiones relacionadas