Autor Beitrag
iX0r
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34

Ubuntu
D6, Lazarus
BeitragVerfasst: Do 05.05.05 09:40 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
// Klassendeklaration

 type TPunkt=class (TObject)
    x:integer;
    y:integer;
    ...
    procedure tpunkt.setze_xy(x_neu,y_neu:integer);
  
  
implementation
{
}
  
  procedure tpunkt.setze_xy(x_neu,y_neu:integer);
begin
  x:=x_neu;
  y:=y_neu;
end;


// so möchte es initilaisieren, geht aber net 

// im interface der hauptform  das folgende:

aktpos:TPunkt;   

// im implementation der hauptfrom das folgende:

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  // aktuellem maus koordinaten speichern (global)
  aktpos.setze_xy(x,y);
  StatusBar1.Panels.Items[0].Text:='x: '+Inttostr(x)+' || '+'y: '+inttostr(y);
end;


Programm beendet imer mit einer Zugriffsverletzung?
Sehe ich nur den Wald vor lauter Bäumen nicht ?

Vielen Dank im Voraus!
iX0r

Update
Komischerweise funktioniert es mit folgendem Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
rocedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var p:TPunkt;
begin
  // aktuellem maus koordinaten speichern (global)
  p.create;
  p.setze_xy(x,y);
  aktpos:=p;
  StatusBar1.Panels.Items[0].Text:='x: '+Inttostr(x)+' || '+'y: '+inttostr(y);

end;

Komische Welt ...
Könnte mir jemand sagen, warum es so reagiert, und nicht auch bei Variante 1 funktioniert?

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 05.05.05 11:03 
Ich sehe in deinem ersten Code, der nicht funktioniert, nicht, wo du aktpos := TPunkt.Create aufrufst :lupe:

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
iX0r Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34

Ubuntu
D6, Lazarus
BeitragVerfasst: Do 05.05.05 11:05 
hatte nur ein  aktpos.create *schäm* !
wenn doch nur die syntax nicht wäre ...

vielen dank!