Autor Beitrag
Sina4ever
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mi 11.10.06 13:24 
Hi,

ich möchte ein einfaches irc beispiel mit den Turbos porgrammieren...da ich ja dort keine Indy Komponenten nutzen kann habe ich bis jetzt folgenden Code:

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:
26:
procedure TForm1.Beenden1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if irc.Connected = true then
  begin
    irc.Disconnect('Offline');
  end;
irc.Free;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  irc := tidirc.Create(Application);

      try
        irc.Connect('euroserv.fr.quakenet.org');
        
      except
        statusbar1.Panels[0].Text := 'Konnte Keine Verbindung herstellen!';
      end;
    
end;



So, jetzt möchte ich auf die Eigenschaft irc.onNotice zugreifen...Wie muss ich das jetzt machen, denn ich möchte in dieser eigenschaft die notices in ein memo schreiben.

sina
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Mi 11.10.06 13:45 
ich weiß zwar nicht was irc is, aber wenn du OnNotice aufrufen willst dann müsste es sowas wie irc.Notice geben. Oder du schreibst ne eigene procedure, die du in OnNotice und an der Stelle aufrufst. Oder ich hab deine Frage net verstanden und erzähl Blödsinn :roll:

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mi 11.10.06 13:50 
ich weiß ja nicht wie ich onnotice deklarieren muss, damit es ausgeführt wird...
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 11.10.06 14:05 
Hallo!

Zuerst einmal: OnNotice ist ein Event, das heißt, Du weißt ihm eine Methode zu, welche ausgeführt werden soll, wenn das entsprechende Ereignis stattfindet.

Die Delphi-Hilfe verrät, dass OnNotice vom Typ "TIdIRCNoticeEvent" ist. Dazu wiederrum schreibt die Delphi-Hilfe:
ausblenden Delphi-Quelltext
1:
TIdIRCNoticeEvent = procedure (ASender: TIdContext; const ANicknameFrom, AHost, ANicknameTo, ANotice: String) of object;					

Damit weißt Du, wie eine Methode aussehen muss, welche Du dem Event zuweisen kannst. Das "of object" bedeuetet dabei, dass es sich tatsächlich um eine Methode handelt, also eine Prozedur, welche zu einem Objekt (wahrscheinlich Deiner Form) gehört.

Sähe dann z.B. so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type
  TForm1 = class(TForm)
  {...}
  public
    procedure MyOnNotice(ASender: TIdContext; const ANicknameFrom, AHost, ANicknameTo, ANotice: String);
  end;

Und dann natürlich noch die entsprechende Implementation.

Eine solche Methode kannst Du dann einfach dem Event zuweisen:
ausblenden Delphi-Quelltext
1:
irc.OnNotice := MyOnNotice;					


Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mi 11.10.06 14:22 
so wirklich verstehe ich das noch nicht, aber ich schau es mir nochmal in ruhe an....

aber bis dahin kannst du mir evtl. noch sagen wieso er: TIdContext nicht kennt...

undefinierter bezeichner...welche unit muss ich noch einbinden, bislang nur idirc!

Sina
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 11.10.06 14:24 
Ich denke, das findest Du durch Benutzung der Hilfe auch selber raus :roll:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mi 11.10.06 14:32 
ok, hab ich dann auch wirklich gefunden...

doch jetzt bekomme ich keine fehler aber hunderte exceptions mit Fehlercode: 1400.

Woran liegt das?
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 11.10.06 14:35 
Wie soll Dir das jemand sagen, der Deinen Quellcode nicht kennt?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Mi 11.10.06 14:42 
Bitte:

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:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, XPMan, StdCtrls, ComCtrls, ExtCtrls, Menus,idirc, idcontext;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Beenden1: TMenuItem;
    N1: TMenuItem;
    Info1: TMenuItem;
    StatusBar1: TStatusBar;
    Panel1: TPanel;
    RichEdit1: TRichEdit;
    XPManifest1: TXPManifest;
    ListBox1: TListBox;
    Splitter1: TSplitter;
    procedure Beenden1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    irc : tidirc;
    procedure MyOnNotice(ASender: TIdContext; const ANicknameFrom, AHost, ANicknameTo, ANotice: String);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure tform1.MyOnNotice(ASender: TIdContext; const ANicknameFrom, AHost, ANicknameTo, ANotice: String);
begin
 ShowMessage('hallo');
end;

procedure TForm1.Beenden1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if irc.Connected = true then
  begin
    irc.Disconnect('Offline');
  end;
irc.Free;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  irc := tidirc.Create(Application);
  irc.OnNotice := MyOnNotice;
      try
        irc.Connect('euroserv.fr.quakenet.org');

      except
        statusbar1.Panels[0].Text := 'Konnte Keine Verbindung herstellen!';
      end;

end;




end.