核心提示:关键代码:functionTForm1.GetSysFocus:Integer; var hOtherWin,OtherThreadID,hFocusWin:integer; begin hOther...
关键代码:
function TForm1.GetSysFocus: Integer;
var
hOtherWin,OtherThreadID,hFocusWin:integer;
begin
hOtherWin:=GetForegroundWindow;
OtherThreadID:=GetWindowThreadProcessID(hOtherWin,nil);
if AttachThreadInput(GetcurrentThreadID,OtherThreadID,True) then
begin
hFocusWin:=GetFocus;
result:=GetFocus;
if HFocusWin<>0 then
try
//SendMessage(GetFocus,WM_COPY,0,0);//书上是这么写的
finally
AttachThreadInput(GetcurrentThreadID,OtherThreadID,False);
end;
end
else result:=GetFocus;
end; //这段代码是得到当前正在输入控件的Handle
全部代码已经打包
迅雷专用高速下载