首页  编辑  

整个系统中的焦点控件

Tags: /超级猛料/OS.操作系统/   Date Created:

get the focus systemwide?

function GetSysFocus: Integer;

var

 hFgWin, FgThreadID, hFocusWin: Integer;

begin

 hFgWin     := GetForegroundWindow;

 FgThreadID := GetWindowThreadProcessID(hFgWin, nil);

 if AttachThreadInput(GetCurrentThreadID, FgThreadID, True) then

 begin

   hFocusWin := GetFocus;

   Result    := GetFocus;

   AttachThreadInput(GetCurrentThreadID, FgThreadID, False);

 end

 else

   Result := GetFocus;

end;