Autor Beitrag
Bergmann89
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Sa 04.09.10 15:14 
Hey,

ich steh grad irgendwie auf'm Schlauch. Ich hab versucht in FPC (Lazarus) ein ganz normales Event zu definieren - so wie in D7 auch - aber er sagt immer, das die Parameteranzahl nich übereinstimmt. kann mir das jmd erklären, oder is das evtl ein Bug? Hier noch der Code (geht mit D7 1a un in FPC spinnt er rum):
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:
unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs; 

type
  TMyEvent = procedure(Sender: TObject; TestParam: Stringof Object;

  { TForm1 }

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    fOnMyEvent: TMyEvent;
    procedure MyEventHandler(Sender: TObject; TestParam: String);
  public
    { public declarations }
  end

var
  Form1: TForm1; 

implementation

{ TForm1 }

procedure TForm1.MyEventHandler(Sender: TObject; TestParam: String);
begin
  ShowMessage(Sender.ClassName + ': ' + TestParam);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  fOnMyEvent := MyEventHandler; //ier kommt der Fehler: Unit1.pas(38,33) Error: Wrong number of parameters specified for call to "MyEventHandler"

end;

initialization
  {$I Unit1.lrs}

end.

MfG Bergmann

_________________
Ich weiß nicht viel, lern aber dafür umso schneller^^
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 04.09.10 15:19 
Mach mal unter den Compileroptionen unter Parsen den Syntax-Modus auf Delphi, ansonsten vermutlich @ voranstellen. Die Option "AnsiStrings verwenden" würde ich auch gleich einschalten.


Zuletzt bearbeitet von delfiphan am Sa 04.09.10 15:23, insgesamt 1-mal bearbeitet
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Sa 04.09.10 15:23 
funzt auch nich...

_________________
Ich weiß nicht viel, lern aber dafür umso schneller^^
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 04.09.10 15:25 
Hab's soeben ausprobiert. Mit -Mdelphi kompilierts, mit -Mobjfpc (Standardeinstellung) kommt deine Fehlermeldung.

Was passiert bei dir, wenn du bei der Zuweisung @ voranstellst?
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Sa 04.09.10 15:27 
Ahh, das geht. Danke :D Da muss man auch erstma drauf komm :?

_________________
Ich weiß nicht viel, lern aber dafür umso schneller^^