关于拖放的问题,请指点!(50分)

  • 主题发起人 主题发起人 nuke
  • 开始时间 开始时间
N

nuke

Unregistered / Unconfirmed
GUEST, unregistred user!
我想作一个类似文件管理器的界面,左边是treeview右边是listview
如何实现从右边拖一个东东到左边的treeview中???
如何得知用户将东东放在了treeview的哪个item中,以及用户拖来的
是listview中的哪个项?
请给出简单例程!
不胜感谢!
新手入门,请多指教!
(不喜欢"请参见****"的回答)
 
implementation
{$R *.DFM}
procedure TForm1.ListBox1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if Button = mbLeft then
begin
Listbox1.DragMode := dmManual;
Listbox1.begin
Drag(False,-1);
end;
end;

procedure TForm1.Label1DragDrop(Sender, Source: TObject;
X, Y: Integer);
begin
if (Sender is TLabel) and (Source is TListBox) then
begin
with Sender as Tlabeldo
begin
Font := (Source as Tlistbox).Font;
Color := (Source as TlistBox).Color;
Caption := (Source as TlistBox).Items[(Source as TlistBox).ItemIndex]
end;
end;
end;

procedure TForm1.Label1DragOver(Sender, Source: TObject;
X, Y: Integer;
State: TDragState;
var Accept: Boolean);
begin
Accept := Source is TLIstBox;
end;

procedure TForm1.TreeView1DragOver(Sender, Source: TObject;
X, Y: Integer;
State: TDragState;
var Accept: Boolean);
begin
Accept := Source is TLIstBox;
end;

procedure TForm1.TreeView1DragDrop(Sender, Source: TObject;
X, Y: Integer);
begin
With (Sender as TTreeView)do
begin
GetNodeAt(X,Y).Text := (Source as TListBox).Items[(Source as TlistBox).ItemIndex];
end;
end;

end.
 
另外:
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject;
X, Y: Integer);
begin
With (Sender as TTreeView)do
begin
ItemS.AddChild (GetNodeAt(X,Y),(Source as TListBox).Items[(Source as TlistBox).ItemIndex]);
end;
end;
 
接受答案了.
 
后退
顶部