listview中如何拖动并保持图标位置? 如题:可以实现随意拖动并保持图标的位置 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的意思是拖动一个NOde??在OnDrag里边写啊 实现 windows 桌面上拖动图标的界面宋体 如何实现 windows 桌面上拖动图标的界面 宋体 // 用 TListView 把 TListView 放在 form 上 ,设定 align:=alclient;添加几个 ListItem,设定大图标 ,ListView.viewstyle:=vsicon下面是代码 unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ImgList, ComCtrls;typeTForm1 = class(TForm)fghd: TListView;ImageList1: TImageList;procedure fghdDragOver(Sender, Source: TObject; X, Y: Integer;State: TDragState; var Accept: Boolean);procedure fghdDragDrop(Sender, Source: TObject; X, Y: Integer);procedure fghdMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}procedure TForm1.fghdDragOver(Sender, Source: TObject; X, Y: Integer;State: TDragState; var Accept: Boolean);beginaccept:=Source is TlistViewend;procedure TForm1.fghdDragDrop(Sender, Source: TObject; X, Y: Integer);varPosPoint:TPoint;beginPosPoint.x:=x;PosPoint.y:=Y;(Source As TListView).Selected.SetPosition(PosPoint);end;procedure TForm1.fghdMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);beginif button=mbleft thenbeginwith sender as TListview dobeginif GetItemAt(x,y)<>nil thenbegindrag(false);end;end;end;end. lion_lh(xmanx) :可以拖动,但拖动位置不精确,能不能控制精确些,多谢!~ 我也遇到过这样的问题这样解决的:在程序里声明两个变量fx,fy : integer在fghdMouseDown里加上fx:=x-(Source As TListView).Selected.leftfy:=y-(Source As TListView).Selected.top在fghdDragDrop里改为PosPoint.x:=x-fx;PosPoint.y:=Y-fy; DELPHI向SQLSERVER存储过程传递参数的问题???急!!! 请教大侠关于Wise Installation System9.02打包问题 关于MEMO读取比较卡。 这个递归哪有错? 有关线程,如何在一个线程中关闭主应用程序。 向高手请教:delphi解析XML串 简单问题 图象数字水印问题~_~(急!急!急!) 为什么我在代码编辑器里面输入不了全角啊,怎么解决啊!! 哪位大哥知道上海达冠科技,拖欠工资,现在找不到他了. 紧急求救高手~~~~~~~~~~~在线等待 delphi 中对word 进行控制时,word 中Paragraphs对象的使用,请高手进
在OnDrag里边写啊
宋体 如何实现 windows 桌面上拖动图标的界面 宋体 // 用 TListView 把 TListView 放在 form 上 ,设定 align:=alclient;添加几个 ListItem,设定大图标 ,ListView.viewstyle:=vsicon下面是代码 unit Unit1;
interface
usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ImgList, ComCtrls;
typeTForm1 = class(TForm)fghd: TListView;ImageList1: TImageList;procedure fghdDragOver(Sender, Source: TObject; X, Y: Integer;State: TDragState; var Accept: Boolean);procedure fghdDragDrop(Sender, Source: TObject; X, Y: Integer);procedure fghdMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);private{ Private declarations }public{ Public declarations }end;
varForm1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.fghdDragOver(Sender, Source: TObject; X, Y: Integer;State: TDragState; var Accept: Boolean);beginaccept:=Source is TlistViewend;
procedure TForm1.fghdDragDrop(Sender, Source: TObject; X, Y: Integer);varPosPoint:TPoint;beginPosPoint.x:=x;PosPoint.y:=Y;(Source As TListView).Selected.SetPosition(PosPoint);end;
procedure TForm1.fghdMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);beginif button=mbleft thenbeginwith sender as TListview dobeginif GetItemAt(x,y)<>nil thenbegindrag(false);end;end;end;
end.
这样解决的:
在程序里声明两个变量fx,fy : integer
在fghdMouseDown里加上
fx:=x-(Source As TListView).Selected.left
fy:=y-(Source As TListView).Selected.top
在fghdDragDrop里改为
PosPoint.x:=x-fx;
PosPoint.y:=Y-fy;