如何获得光标位置?

Reiner9000 2003-10-15 06:11:43
谁能告诉我 怎么获得光标位置 ?
在一个窗体上显示一个数据库的内容 光标在某一个字段上 怎么定位?
我是说 数据库有4个字段 在显示的数据库下面放4个Edit 开始的时候4个Edit都不可见 光标定位在哪个字段 相应地这个字段下面的Edit就出现
...全文
168 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
angelface 2003-11-04
  • 打赏
  • 举报
回复
:-O
zzzzzzzzzzzzz 2003-11-04
  • 打赏
  • 举报
回复
var
p:tpoint;


getcursorpos(p);
saien 2003-11-03
  • 打赏
  • 举报
回复
@_@
sihybunbun 2003-10-17
  • 打赏
  • 举报
回复
这个情况我也曾经遇到,搞了很久没有解决,我的结论是:
这种编程风格不可取,想别的方法吧
lw549 2003-10-17
  • 打赏
  • 举报
回复
*_*
Reiner9000 2003-10-16
  • 打赏
  • 举报
回复
ghyghost(爱国人士) :你把你的程序要求详细一下

如下:

1:增加一个“设置”按钮,用来修改数据库中的项。(改成“修改”按纽了)
例如: 将电视的价格提高100元。
将掌上电脑的型号改变。

2:增加一个“高级设置”按钮,用来添加数据项。(改成“添加”按纽了)
增加一个新的可选物品,包括名字,价格等数据。
在随即选取的时候,可以选择到这个物品。
Reiner9000 2003-10-16
  • 打赏
  • 举报
回复
hiflower(花) :晕,你的字段用什么显示的?DBGrid? Label?
用 OnMouseMove 事件不就行了

谢谢您~!我的字段是用DBGrid显示的 您能帮我把代码写出来吗?
IORILI 2003-10-16
  • 打赏
  • 举报
回复
^-^
Reiner9000 2003-10-16
  • 打赏
  • 举报
回复
那你还是没说清楚啊 知道字段名有什么用 要定位到具体的内容的

hiflower(花) :
呵呵,那是上一行的注释内容,CSDN 帮我换行了。
知道了字段名,你可以自己做了
hiflower 2003-10-16
  • 打赏
  • 举报
回复
呵呵,那是上一行的注释内容,CSDN 帮我换行了。
知道了字段名,你可以自己做了
Reiner9000 2003-10-16
  • 打赏
  • 举报
回复
hiflower(花) :

谢谢您~! 我试一下 成功了就给分 不过 您的程序是不是没写完
Reiner9000 2003-10-16
  • 打赏
  • 举报
回复
hiflower(花) :

谢谢您~! 我试一下 成功了就给分
liyangyao970 2003-10-16
  • 打赏
  • 举报
回复
up
hiflower 2003-10-16
  • 打赏
  • 举报
回复
procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
RowIndex,ColumnIndex:Integer;
begin
RowIndex:=DBGrid1.MouseCoord(X,Y).Y-1;
ColumnIndex:=DBGrid1.MouseCoord(X,Y).X-1;//根据 ColumnIndex 可得知字段名:Columns[ColumnIndex].FieldName
end;
hiflower 2003-10-15
  • 打赏
  • 举报
回复
晕,你的字段用什么显示的?DBGrid? Label?
用 OnMouseMove 事件不就行了
saien 2003-10-15
  • 打赏
  • 举报
回复
GetCursorPos
GetCaretPos
我不懂电脑 2003-10-15
  • 打赏
  • 举报
回复
The GetCursorPos function retrieves the cursor's position, in screen coordinates.

BOOL GetCursorPos(

LPPOINT lpPoint // address of structure for cursor position
);


Parameters

lpPoint

Points to a POINT structure that receives the screen coordinates of the cursor.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The cursor position is always given in screen coordinates and is not affected by the mapping mode of the window that contains the cursor.
The calling process must have WINSTA_READATTRIBUTES access to the window station.

See Also
dickeybird888 2003-10-15
  • 打赏
  • 举报
回复
(@ * @)
  • 打赏
  • 举报
回复
你把你的程序要求详细一下
Reiner9000 2003-10-15
  • 打赏
  • 举报
回复
to ghyghost(爱国人士) :

程序好象不大对,我要得到的是数据库中字段的名字

__________________________________________________________________________________
procedure TForm1.Timer1Timer(Sender: TObject);
var
cursor_postion:tpoint;
handle:hwnd;
class_name:pchar;
intResult:integer;
strClassName:string;
begin
Timer1.Enabled :=false;
getcursorpos(cursor_postion);
handle:=windowfrompoint(cursor_postion);
if handle<>0 then
begin
GetMem(class_name,256);
intResult:=getclassname(handle,class_name,256);
//showmessage(inttostr(intResult));//判断是否得到类型
form1.Memo1.Lines.Add(Trim(string(class_name)));
FreeMem(Class_Name);
end;
timer1.Enabled :=true;
end;


加载更多回复(8)

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧