procedure TForm1.Button1Enter(Sender: TObject);
var
FocusWnd: HWND; // this will hold the window handle
ClassName: array[0..255] of char; // this will hold the class name
begin
{get the handle of the window that currently has input focus}
FocusWnd:=GetFocus;
{get the class name of this window}
GetClassName(FocusWnd,ClassName,255);
{display the class name of the window with input focus}
Label2.Caption:=string(ClassName)+' has input focus.'
end;