function input_process(var str : array of m_H : THandle) : boolean ; stdcall;<br>var<br> h_Wnd : HWND;<br> num : array[0..3] of char ;<br> dwThreadID, dwCurrentThreadID : DWORD;<br> pt: TPoint;<br> CR_flag : BYTE;<br> old_hkl ,myhkl: HKL;<br> setflag : integer;<br> i : integer;<br> main_handle : THandle;<br> h_imc,h2 : HIMC;<br> test :HWND;<br> // h_point : LPSTR;<br>begin<br> main_handle := Frm_H;<br> CR_flag := $0d;<br> setflag := 0;<br> //检查哪个窗口掌握光标<br> GetCursorPos(pt);<br> h_Wnd := WindowFromPoint(pt);<br> //获得光标所有者的线程ID<br> dwThreadID := GetWindowThreadProcessId(h_Wnd,nil);<br> //获得当前线程的ID<br> dwCurrentThreadID := GetCurrentThreadId();<br> old_hkl := GetKeyBoardLayOut(0); //保存旧的HKL<br> if (dwCurrentThreadID <> dwThreadID) then //如果输入焦点在别的线程<br> begin<br> if AttachThreadInput(dwThreadID,dwCurrentThreadID,True) then //连接线程<br> begin<br> h_Wnd := GetFocus();{因为线程已连接,所以能取得正确的Handle}<br> PostMessage(h_Wnd,WM_CHAR,WPARAM(str),1);<br> AttachThreadInput(dwThreadID,dwCurrentThreadID,False); //解除线程连接<br> end;<br> ...