实现windows桌面上拖动图标的界面

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
宋体 如何实现windows桌面上拖动图标的界面
 
宋体 //用TListView把TListView放在form上,设定align:=alclient;
添加几个ListItem,设定大图标,ListView.viewstyle:=vsicon
下面是代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, ComCtrls;
type
TForm1 = 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;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.fghdDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
accept:=Source is TlistView
end;
procedure TForm1.fghdDragDrop(Sender, Source: TObject; X, Y: Integer);
var
PosPoint:TPoint;
begin
PosPoint.x:=x;
PosPoint.y:=Y;
(Source As TListView).Selected.SetPosition(PosPoint);
end;
procedure TForm1.fghdMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
begin
with sender as TListview do
begin
if GetItemAt(x,y)<>nil then
begindrag(false);
end;
end;
end;
end.
 

Similar threads

I
回复
0
查看
728
import
I
I
回复
0
查看
570
import
I
I
回复
0
查看
515
import
I
I
回复
0
查看
715
import
I
后退
顶部