var<br> h : hwnd;<br> idself : hwnd;<br> idactive : hwnd;<br>begin<br> h := GetForeGroundWindow;<br> idself := GetWindowThreadProcessID(Handle);<br> idactive := GetWindowThreadProcessID(h);<br> if h > 0 then<br> begin<br> AttachThreadInput(idactive, idself, True);<br> h := GetFocus;<br> Caption := IntToStr(h); //这里的h就是焦点所在控件的句柄<br> AttachThreadInput(idactive, idself, False);<br> end;<br>end;