Autor Beitrag
D0P3 F!$H
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mi 25.06.03 17:44 
Weiss nicht genau, wo das hier reinkommt ... hab ja auch schon lange nichts mehr gepostet! :roll:

Also wir sollen in der Schule ein "Spiel" programmieren, haben auch eine kurze Anleitung mit einigen Prozeduren drauf. Dort steht auch Folgendes:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var Panel: TPanel;
...
procedure THauptForm.PanelErzeugen
begin
 ...
 Panel.OnClick := PanelWeg;
 ...
end;

PanelWeg ist eine Prozedur die das Panel, unsichtbar macht, wennman auf da Panel klickt.

Nur geht das bei mir nicht! Mein Quellcode:
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:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
unit Hauptformular;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Menuformular;

type
  THauptF = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure PanelErstellen;
    procedure PanelLoeschen;
  end;

var
  HauptF: THauptF;
  PanelN: TPanel;
  PanelAnzahl: Integer;

implementation

{$R *.dfm}

procedure THauptF.FormCreate(Sender: TObject);
var i: Integer;
begin
 MenuF := TMenuF.Create(HauptF);
 MenuF.Show;
 PanelAnzahl := 0;
 MenuF.ListBox1.Clear;
 Randomize;
 for i := 1 to 5 do PanelErstellen;
 MenuF.ListBox1.Items.Add(IntToStr(PanelAnzahl));
 MenuF.ListBox1.Font.Size := 50;
end;

procedure THauptF.PanelErstellen;
begin
 PanelN := TPanel.Create(HauptF);
 PanelN.Left := Random(Round(HauptF.Width - PanelN.Width));
 PanelN.Top := Random(Round(HauptF.Height - PanelN.Height));
 PanelN.Width := 40;
 PanelN.Height := 40;
 PanelN.Caption := 'X';
 PanelN.OnClick := PanelLoeschen;
 PanelN.Parent := HauptF;
 PanelN.Show;
 Inc(PanelAnzahl);
end;

procedure THauptF.PanelLoeschen;
begin
 ShowMessage('a');
end;

end.


Es wird beim Starten die Zeile PanelN.OnClick := PanelLoeschen; markiert mit der Begründung Incompatible Types: 'Parameter lists differ'

Wo ist der Fehler?

Moderiert von user profile iconAya: Topic verschoben.
Moderiert von user profile iconTino: Code- durch Delphi-Tags hinzugefügt.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 25.06.03 17:49 
Ein OnClick-Ereignis ist vom Typ TNotifyEvent. Das bekommt einen Parameter "Sender". Diesen Parameter besitzt die Prozedur "panelloeschen" nicht.

Und wie zum Teufel kommst Du drauf, dass dies hier im "Multimedia / Spiele / Grafik" richtig ist :?:

MfG,
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
D0P3 F!$H
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mi 25.06.03 18:07 
Weils ein Spiel werden soll =)
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 25.06.03 18:09 
aber die frage, war ja eine andere... ich würde sagen es kommt unter vcl oder ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 26.06.03 09:23 
@D0P3 F!$H: Ist das Problem jetzt gelöst? :roll:
Ist die Frage beantwortet? Das Problem gelöst?

Dann klicke hier, um das Thema entsprechend zu markieren!