怎样捕获ListView中鼠标点击的坐标!?? 各位大虾好!!!小弟想问一下在ListView中点击子项后怎样捕获鼠标在ListView内的坐标,上次在这里问过,但没有合适的答案,想自己探索一下,但还是摸不着头脑,实在没有办法了,还请各位大虾帮助一下,先谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面程序在D7下测试通过------------------------------------unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls;type TForm1 = class(TForm) ListView1: TListView; Button1: TButton; procedure Button1Click(Sender: TObject); procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);VAR MyItem:TListItem; I:Integer;begin for I:=1 to 10 do begin MyItem:=listView1.Items.Add; MyItem.Caption:='项目'+IntToStr(I); end;end;procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin if listview1.SelCount <> 0 then begin showmessage('x:'+IntToStr(x)+#13+'y:'+IntToStr(y)); end;end;end. 思路:在鼠标点下的时候判断是否有项目被选中,如果有的话,就输出x,y的值 button1用来创建10个items 对不起,小弟说错话了,应该是:“能不能用消息机制来实现”,多了个‘我’字,请大虾们见谅,小弟正在学消息,本来是在学VCL的,没有办法,都要学的。 变量的位置 用DBGrid对一个表两个字段值进行统计求和并在底部显示合计 如何将导出的Excel的某行背景色变成兰色,谢谢 怎么实现查找下一个功能? >>>>>如何让计算机发出特定的报警声<<<<<<< 用BDE连接服务器问题 DBGridEh的问题,在线等待 请问鼠标右击前触发的事件是那个? Delphi不错的(最先进的)Remobjects分布式多层ERP源码 delphi中怎样不连接数据库直接处理表格? 菜鸟求助(问题简单) 望高手们别见笑 如何将exe文件的图标显示在“按钮”上(TButton,TBitBtn,TSpeedButton都行)
------------------------------------
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
ListView1: TListView;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
VAR MyItem:TListItem;
I:Integer;
begin
for I:=1 to 10 do
begin
MyItem:=listView1.Items.Add;
MyItem.Caption:='项目'+IntToStr(I);
end;
end;procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if listview1.SelCount <> 0 then
begin
showmessage('x:'+IntToStr(x)+#13+'y:'+IntToStr(y));
end;
end;end.
button1用来创建10个items