Internal]
http://delphi.ktop.com.tw/topic.asp?topic_id=47386
Function getCaretPosition (var apoint: tpoint): boolean;
Var w: hwnd;
AID, MID: DWORD;
Begin
Result: = FALSE;
W: = getForeGroup;
IF W <> 0 THEN
Begin
AID: = GetWindowThreadProcessId (W, NIL);
MID: = getCurrentThreadID;
IF AID <> MID THEN
Begin
If attachthreadinput (mid, aid, true) THEN
Begin
W: = getfocus;
IF W <> 0 THEN
Begin
Result: = getcaretpos (apoint);
Windows.ClientToscreen (W, Apoint);
END;
AttachthReadInput (MID, AID, FALSE);
END;
END;
END;
END;
Procedure TFORM1.TIMER1TIMER (Sender: TOBJECT);
VAR
Notepad: hwnd;
PT: TPOINT;
Begin
Notepad: = FindWindow ('NOTEPAD', NIL);
IF notepad <> 0 THEN
IF getCaretPosition (Pt) THEN
Begin
Label1.caption: = (Format ('Caret Location:% D% D', [PT.x, Pt.y]));
//Setcursorpos(pt.x, pt.y);
END;
END;