GetFocus
有关以下示例的说明,请参阅文档中的备注部分。
function GetFocus: HWND;
var
Wnd: HWND;
TId, PId: DWORD;
begin
Result := windows.GetFocus;
if Result = 0 then begin
Wnd := GetForegroundWindow;
if Wnd <> 0 then begin
TId := GetWindowThreadProcessId(Wnd, PId);
if AttachThreadInput(GetCurrentThreadId, TId, True) then begin
Result := windows.GetFocus;
AttachThreadInput(GetCurrentThreadId, TId, False);
end;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)