Autor Beitrag
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mo 31.01.05 22:45 
Hi
Ich versuche verzweifelt eine Drag&Drop funktion in mein TreeView zu bauen. :(

ausblenden Delphi-Quelltext
1:
2:
  Label1.Caption := IntToStr(X);
  Label2.Caption := IntToStr(Y);
Egal in welche Drag oder Drop funktion ich diesen Text schreibe, er gibt mir nie die Koordinaten. Die Labels bleiben immer unverändert. Das heist er kann das Item ja garnicht finden. :gruebel:
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: Di 01.02.05 13:50 
TreeView1DragOver und Dragmode:=dmAutomatic
Zeig dir alles dafür an..

mfg herzi
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 03.02.05 18:24 
Ok, ich wollte das jetzt mit dem Code aus der Delphi-Hilfe machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TMainForm1.TreeView1DragDrop(Sender, Source: TObject; X,
  Y: Integer);
var
  AnItem: TTreeNode;
  AttachMode: TNodeAttachMode;
  HT: THitTests;
begin
  if TreeView1.Selected = nil then Exit;
  HT := TreeView1.GetHitTestInfoAt(X, Y);
  AnItem := TreeView1.GetNodeAt(X, Y);
  if (HT - [htOnItem, htOnIcon, htNowhere, htOnIndent] <> HT) then
  begin
    if (htOnItem in HT) or (htOnIcon in HT) then AttachMode := naAddChild
    else if htNowhere in HT then AttachMode := naAdd
    else if htOnIndent in HT then AttachMode := naInsert;
    TreeView1.Selected.MoveTo(AnItem, AttachMode);
  end;
end;

Aber wenn ich es ausprobieren will verändert sich der Cursor immer zum Verbotenzeichen und es passiert nichts. :(
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Do 03.02.05 18:50 
wie sieht dein dragover-ereignis aus?

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 03.02.05 19:00 
Ich hab keins :lol:
Mom...
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Do 03.02.05 19:03 
Coder hat folgendes geschrieben:
Ich hab keins :lol:
Mom...

dann brauchst du dich nicht zu wundern :roll:

du mußt dort das accept setzen, wie es auch in der Hilfe steht.

ausblenden Delphi-Quelltext
1:
  Accept := Source is Ttreeview;					

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Do 03.02.05 19:04 
Hallo,

du musst Drag & Drop im Ereignis OnDragOver schon erlauben ;), das heisst die Variable Accept auf wahr setzen!

Gruß Hape!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 03.02.05 19:20 
Jo hab ich auch grad gemerkt :lol:
Thx