输入法相关,如何定位光标(caret)的屏幕坐标, 我的方法在word 中不行,为什么
以下为我的代码:
function GetCaretScreenPos() : TPoint;
var
aHandle : THandle;
aThread : THandle;
aFocus : THandle;
aFocusRect : TRect;
aCaretPos : TPoint;
i : Integer;
aRes : LongBool;
begin
aHandle := GetForegroundWindow();
aThread:=GetWindowThreadProcessId(aHandle);
AttachThreadInput(GetCurrentThreadId,AThread,True);
SetActiveWindow(aHandle);
aFocus := GetFocus;
GetCaretPos(aCaretPos) then
windows.ClientToScreen(aFocus, aCaretPos);
AttachThreadInput(GetCurrentThreadId,AThread,False);
Result.X := aCaretPos.X;
Result.Y := aCaretPos.Y;
end;
在其它所有窗口(edit combobox, richedit)中都可以, 只有 Word 中不可用不知为什么,
我不想用VBA 来实现.