我需要的不是光标所在行列数,儿是相对于窗口或者屏幕的坐标值。
解决方案 »
- 帮帮看看D 2009导出到EXCEL的问题...
- 关于DELPHI怎样向SYBASE的数值型字段赋值
- 求一sql语句,怎么查询?
- 怎样把导出到EXECL的数据,用程序控制让它不能修改?
- 关于LED的显示!!!
- 怎么样在软件正式启用之前进行用户密码登录?
- 使用query控件作查询,如何删除数据表中的记录?
- 寻求游戏脚本,要求是rpg的
- 为什么在WIN2000下编的程序与WIN98下的界面不一样,有什么解决的方法?
- 关于数据库访问冲突的问题,高分求救 急!!!急!!急!!!急!!!急!!!急!!急急
- 关于api(CreateColorTransform )在帮助里都查不到,该怎样用
- 高手请进,这个统计用一条Select语句能不能完成?在线等!
var w: HWND;
aID, mID: DWORD;
begin
Result:= False;
w:= GetForegroundWindow;
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;
//Small demo: set cursor to active caret position
procedure TForm1.Timer1Timer(Sender: TObject);
var
Pt: TPoint;
begin
if GetCaretPosition(Pt) then
begin
ListBox1.Items.Add(Format('Caret position is %d %d', [Pt.x, Pt.y]));
SetCursorPos(Pt.X, Pt.Y);
end;
end;
其中Edit1是你要找光标的控件
function GetCaretPosition(var APoint: TPoint): Boolean;
begin
Result := False;
if Form1.Edit1.Focused then
begin
Result:= GetCaretPos(APoint);
Apoint := Form1.Edit1.ClientToScreen(APoint);
Result := True;
end;
end;