Autor Beitrag
Metty
Hält's aus hier
Beiträge: 3

WindowsXP-SP2, Linux Debian
Delphi6-Professional
BeitragVerfasst: So 25.09.05 17:11 
Also mein Problem ist folgendes:
Ich soll für Informatik ein "Fangmich"-Spiel mit Panels programmieren...
Das Panel, auf das ich dann klicke wird nicht zerstört,
Fehler: "AccesViolation"

ausblenden 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:
procedure Tmainform.panelcreate;
begin
  pan := TPanel.Create(mainform);
  pan.Parent := mainform;
  pan.Name := 'pan' + IntToStr(pan_anzahl);
  pan.Width := 40;
  pan.Height := 40;
  pan.Caption := 'F';
  pan.Color := clYellow;
  pan.Left := random(mainform.Width-50);
  pan.Top := random(mainform.Height-60);
  pan.OnClick := panelclose;
  pan.Show;
  inc(pan_anzahl);
end;

procedure Tmainform.panelclose(Sender: TObject);
begin
  TPanel(Sender).Free;
  inc(punkte);
  setpoints;
  dec(pan_anzahl);
//  if TPanel = nil then
//  timer.Enabled := false;
end;


Ich komm einfach nicht weiter :(
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: So 25.09.05 17:48 
Sicher, dass in der Sender in Panelclose ein TPanel ist?

_________________
Programmers never die, they just GOSUB without RETURN
Metty Threadstarter
Hält's aus hier
Beiträge: 3

WindowsXP-SP2, Linux Debian
Delphi6-Professional
BeitragVerfasst: So 25.09.05 17:59 
Hmmm...
Wenn ich den Sender als TPanel deklariere...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure Tmainform.panelclose(Sender: TPanel);
{...}

pan.OnClick := panelclose;

kommt bei der OnClick-Zuweisung:
Incompatible Types: TObject and TPanel


Sorry, aber bin aber noch im Lernstadium ^^
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: So 25.09.05 18:01 
www.delphi-forum.de/...highlight=komponente

ist das gleiche Problem, lise dir den Thread mal durch.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Metty Threadstarter
Hält's aus hier
Beiträge: 3

WindowsXP-SP2, Linux Debian
Delphi6-Professional
BeitragVerfasst: So 25.09.05 18:20 
Danke, das hat mein Problem gelöst ;)
Hatte zwar schon mittels SuFu gesucht,
aber wahrscheinlich nach dem falschen :mrgreen: