怎样实现拖动功能?

ygb321 2003-10-08 02:27:27
我想在软件里实现想WINDOWS桌面样的东东,要求所有的图标能拖动,并且能像回收站样能将图标放在里面(只要能判断有图标放在它上面就行),我用ListView它不能实现图标拖动,大家有什么办法实现?
...全文
90 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangcz 2003-11-12
  • 打赏
  • 举报
回复
This code comes from an application that contains a list box and three labels, each with a different font and color. The DragMode property for each of the labels is dmAutomatic. The user can select a label and drag it to a list box and drop it. When the label is dropped, the items in the list box assume the color and font of the dropped label.
This OnDragOver event handler permits the list box to accept a dropped label:

procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);

begin
Accept := Source is TLabel;

end;

This OnDragDrop event handler implements the drop behavior.

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);

begin
if (Sender is TListBox) and (Source is TLabel) then
begin
with Sender as TListBox do
begin
Font := (Source as TLabel).Font;
Color := (Source as TLabel).Color;
end;
end;
end;
WuLoveXue 2003-10-08
  • 打赏
  • 举报
回复
没做过,帮你顶下
IORILI 2003-10-08
  • 打赏
  • 举报
回复
listview可以实现拖动,这个问题前面提过,你搜一下,就能找到

5,388

社区成员

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

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