Autor Beitrag
Hansi@OMG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Sa 03.01.04 19:22 
Ich kriege, wenn ich versuche ein Drag and Drop zwischen Form1 und Form2 zu realisieren immer eine Zugriffsverletzung vom Debugger.
Egal mit was für Daten oder Komponenten.
Geht das gar nicht oder muss ich da über einen Umweg arbeiten?

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
ErnestoChe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 528

Win 2000 pro, CRUX 2.0
Delphi 6 Pers, Open K3
BeitragVerfasst: Sa 03.01.04 19:39 
Hi,

das geht schon. Wie sieht denn dein Code aus? Vor allem das OnDragOver und OnDragDrop von Form2.

MFG

- Ernesto -
Hansi@OMG Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Sa 03.01.04 21:07 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm2.Planner1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if source = form1.listview2 then accept :=true;
end;

procedure TForm2.Planner1DragDropItem(Sender, Source: TObject; X,
  Y: Integer; PlannerItem: TPlannerItem);
var pit:tplanneritem;
begin
pit.Create(planner1.Items);
pit:=planner1.Items.Add;
pit.CaptionText:=form1.ListView2.ItemFocused.Caption;
pit.Text.Add(form1.ListView2.ItemFocused.SubItems.Text);
pit.free;
end;


Das ist der Code der in der form2 verwendet wird.
Ich habe das allerdings auch zu Testzwechen mit 2 identischen listviews und 2 listboxen probiert, dass ging auch nicht. Es kommt grundsätzlich die Meldung "Zugriffsverletzung"

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
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: Sa 03.01.04 21:11 
ich hab mir den rest nicht durchgeleswn aber
Zitat:

pit.Create(planner1.Items);

so erstellt man keine Objekte, deine AV ist kein wunder.
ausblenden Delphi-Quelltext
1:
objekt:=TObjekt.create;					


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Hansi@OMG Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Sa 03.01.04 21:22 
Das ist allerdings wirklich nicht der springende Punkt.
Glaub mir, ich habs mit jeder möglichen Schreibweise probiert.
Die letzte hab ich aus reiner Verzweiflung probiert.

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
ErnestoChe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 528

Win 2000 pro, CRUX 2.0
Delphi 6 Pers, Open K3
BeitragVerfasst: Sa 03.01.04 23:30 
Hi,

ok, ich weiss jetzt nicht was TPlanner für eine Komponente ist, aber ich denke mal etwas ListView ähnliches und das man auf ähnliche Art Items hinzufügt. Abgesehen davon, dass du das TPLannerItem falsch erstellst, denke ich dass du mit Create kein neues TPlannerItem zu erstellen brauchst da planner1.Items.Add bereits ein TPlannerItem zurückgeben sollte. Probier es mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm2.Planner1DragDropItem(Sender, Source: TObject; X,
  Y: Integer; PlannerItem: TPlannerItem);
var
  pit: TPlannerItem;
begin
  pit := planner1.Items.Add;
  pit.CaptionText := Form1.ListView2.ItemFocused.Caption;
  pit.Text.Add(Form1.ListView2.ItemFocused.SubItems.Text);
end;


Falls du immer noch eine Acces Violation kriegst, dann geh mal den Code mit dem Debugger durch und poste in welcher Zeile genau die AV ausgelöst wird.

MFG

- Ernesto -
Hansi@OMG Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: So 04.01.04 11:10 
Es funktioniert, danke.
Ich versteh zwar nicht, warum es auf einmal funktioniert, aber trotzdem danke.

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?