如何得到鼠标经过listview每一行的各列信息! 当鼠标经过listview时如何通过消息获得每一行的信息!谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TForm1.ListView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);var item: TListItem;begin item := ListView1.GetItemAt(X, Y); if (item <> nil) then Self.Caption := 'Mouse at: ' + item.Caption;end; “通过消息”什么意思?你的意思是想获得外部程序的ListView的信息?那没做过…… 通过在OnMouseMove事件处理函数里判断坐标位置,提取所在位置的行信息。ListView有个函数function GetItemAt(X, Y: Integer): TListItem; uses CommCtrl;procedure TForm1.ListView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);var item: TListItem; lvhti: LV_HITTESTINFO;begin item := ListView1.GetItemAt(X, Y); if (item <> nil) then Caption := 'Mouse at: ' + item.Caption else begin lvhti.pt.X := X; lvhti.pt.Y := Y; ListView_SubItemHitTest(ListView1.Handle, @lvhti); if Assigned(ListView1.Items[lvhti.iItem]) and (ListView1.Items[lvhti.iItem].SubItems.Count >= lvhti.iSubItem) then Caption := 'Mouse at:' + ListView1.Items[lvhti.iItem].SubItems[lvhti.iSubItem - 1]; end;end; konhon(优华)兄的做法有点接近了,但是我需要鼠标任意一行时得到该行的所有列的信息,如何做呢,上述的做法只能得到鼠标经过某一行某一列的信息,还望指点,谢! 问题解决了,谢谢konhon兄的指点,谢了! 在这里顺便问一下,TImage控件里如何发生KeyPress事件,有办法吗?谢! 在这里顺便问一下,TImage控件里如何发生KeyPress事件,有办法吗?谢!不知道你要干什麼??? 有一个简单的方法,将ListView的RowSelect设置为True(即允许整行选择),然后还是用我的代码就可以解决问题了,至于其它列的信息,通过item.SubItems来获取即可 欢迎加入Borland DELPHI女程序员,参与群里技术讨论!欢迎女孩子,也欢迎男孩子参与技术讨论!群号15154361 樓主一個貼問了好幾個問題呀.樓主信譽分好低喲, 請一定要結貼喲.如何在状态里实现滚动的字幕效果,unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, StdCtrls;type TForm1 = class(TForm) StatusBar1: TStatusBar; Timer1: TTimer; Label1: TLabel; ProgressBar1: TProgressBar; procedure StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } StatusDrawRect: TRect; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);begin StatusDrawRect := rect;end;procedure TForm1.FormCreate(Sender: TObject);begin label1.Parent := statusBar1; label1.Caption := 'abc'; label1.top := StatusDrawRect.Top + 5; label1.Left := StatusDrawRect.Left;end;procedure TForm1.Timer1Timer(Sender: TObject);begin label1.Left := label1.Left + 1; if Label1.Left > StatusBar1.Width + 5 then Label1.Left := StatusDrawRect.Left;end;end. 用F1Book做的ACTIVEX在IE8中的问题 sql server 2000 如何插入多条记录? 请问如何让BitBtn读入TImage(或者TPicture)中的图片? 送我一个dbgrideh,我给他30分~ 接口声明问题 请教一个网络的问题,在线等待 在DELPHI中与ACCESS数据库相联,如何对ACCESS进行加密??请大家帮忙! 请问delphi中的相对目录是怎样写的啊? 窗口显示 这一句错那了,帮忙指出吧。 绑定数据集查询处理问题。。。 一个简单但可能也不简单的关于循环的问题——————在线等待!!!!
Y: Integer);
var
item: TListItem;
begin
item := ListView1.GetItemAt(X, Y);
if (item <> nil) then Self.Caption := 'Mouse at: ' + item.Caption;
end;
Y: Integer);
var
item: TListItem;
lvhti: LV_HITTESTINFO;
begin
item := ListView1.GetItemAt(X, Y);
if (item <> nil) then
Caption := 'Mouse at: ' + item.Caption
else
begin
lvhti.pt.X := X;
lvhti.pt.Y := Y;
ListView_SubItemHitTest(ListView1.Handle, @lvhti);
if Assigned(ListView1.Items[lvhti.iItem])
and (ListView1.Items[lvhti.iItem].SubItems.Count >= lvhti.iSubItem) then
Caption := 'Mouse at:' + ListView1.Items[lvhti.iItem].SubItems[lvhti.iSubItem - 1];
end;
end;
上述的做法只能得到鼠标经过某一行某一列的信息,还望指点,谢!
樓主信譽分好低喲, 請一定要結貼喲.如何在状态里实现滚动的字幕效果,unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls;type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Timer1: TTimer;
Label1: TLabel;
ProgressBar1: TProgressBar;
procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
StatusDrawRect: TRect;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
StatusDrawRect := rect;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
label1.Parent := statusBar1;
label1.Caption := 'abc';
label1.top := StatusDrawRect.Top + 5;
label1.Left := StatusDrawRect.Left;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
label1.Left := label1.Left + 1;
if Label1.Left > StatusBar1.Width + 5 then
Label1.Left := StatusDrawRect.Left;
end;end.