Hola de nuevo.
Ampliando el alcance podes hacer:
Código Delphi
[-]
function GetFocusedControlName(const FormName:string): TWinControl;
var
i: Integer;
begin
Result:= nil;
for i := 0 to Screen.FormCount-1 do
if (Screen.Forms[i].Name = FormName)and(Screen.Forms[i].Visible) then
begin
Result:= Screen.Forms[i].ActiveControl;
Exit;
end;
end;
Ejemplo de uso:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
var
WC: TWinControl;
begin
WC:= GetFocusedControlName('Form2');
if Assigned(WC) then
ShowMessage(WC.Name);
end;
De este modo obtenes el nombre del control que tenga el foco en cualquier Form visible, cuya unidad haya sido incluida en la unidad actual.
Saludos
