Autor Beitrag
neuling82
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mi 30.07.03 14:21 
Hey Leute, ich habe versucht in meine Selbstgeschriebene Komponente einen Timer zu initialisieren... der Code sieht aus wie folgt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
type TmyCompo = class(Tcomponent)
 private
 timer1: TTimer;
 procedure timer1timer(sender: TObject);
 procedure xy;
end;

implementation

procedure TmyCompo.xy;
begin
 timer1:=TTImer.create;
 timer1.intervall:=1000;
 timer1.ontimer:=timer1timer;
 timer1.enabled:=true;
end;

procedure TMyCompo.timer1timer;
begin
*********HIER SPRINGT ER NIE REIN!!!!*********** warum??
end;


warum springt er nie in die Procedure TMyCompo.timer1timer rein??
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Mi 30.07.03 14:27 
hast wohl insertControl(timer1) vergessen !

_________________
mfg
Tana´Ri
neuling82 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mi 30.07.03 14:29 
wo muss dass denn eingefügt werden? Was macht es denn genau? Werde da aus der Onlinehilfe nicht schlau...
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Mi 30.07.03 14:32 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TmyCompo.xy; 
begin 
 timer1:=TTImer.create; 
 timer1.intervall:=1000
 timer1.ontimer:=timer1timer; 
 timer1.enabled:=true;
 insertConrol(timer1); 
end;


denk daran bevor du das Timerobjekt wieder frei gibst das Control zu entfernen, d.h.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
... z.b. im OnDestroy 

removeControl(timer1);
timer1.Free;


Moderiert von user profile iconMarc: Delphi-Tags hinzugefügt.

_________________
mfg
Tana´Ri
neuling82 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mi 30.07.03 14:36 
der Compiler sagt er kenne diesen Befehl nicht, muss ich noch eine Unit einfügen, denn ich schreiben wie gesagt eine Komponente der Klasse TComponent) Diese Komponente ist nicht visual!
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Mi 30.07.03 14:46 
sorry hatte ich gar keine acht in diesem fall muss es natürlich

insertComponent(timer1);

removeComponent(timer1);

heißen :)

_________________
mfg
Tana´Ri
neuling82 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mi 30.07.03 16:45 
ich habe jetz ne ganze weile herumgebastelt, es klappt einfach nicht! Liegt es evtl. daran, dass das erreignis onTimer garnicht aufgerufen wird??
RFZ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: Mi 30.07.03 18:01 
Titel: selbes Problem
Moin, ich hab genau das selbe Problem.
Ausserdem würd ich gern auf ne eigene Klasse für den Timer verzichten, da ich nur einen brauche...
Ich hoffe jemand weiss Rat...

cu RFZ
N3tw124rd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75


D5 Prof.
BeitragVerfasst: Do 31.07.03 09:02 
Hi,

bei mir sieht es so ähnlich aus...
Ich habe eine Client Komponente created doch das event onError wird nie durchlaufen...
Ich denke das insertControl oder insertcomponent bestimmt der Weg ist.Aber welche Klasse enthält den Befehl ??
Habe classes schon drin da sollte insertcomponent drin sein macht er aber nicht...

MFG N3tw124rd
neuling82 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Do 31.07.03 09:17 
Hey, also bei mir klappts jetzt, ich hatte nur die Unit für Linux (Kylix) eingebunden, das geht halt net ..... :wink:
N3tw124rd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75


D5 Prof.
BeitragVerfasst: Do 31.07.03 09:22 
Hi,
habe gemerkt das ich den Befehl im Formular ausführen muß es verläuft auch alles gut die Componente wird im Formular Registriert ...
Die Komponente wird auch wieder schön rausgenommen mit removecomponent...
Aber er fällt immer noch nicht in das onError Event ?!?!

Das ganze sieht folgendermaßen aus...

Ein Formular mit einem Knopf, eine Unit mit meiner ClientSocket kompo...
ich rufe das Create meiner Unit auf in der die ClientSocket-kompo created wird und auch gleich das event zu gewiesen bekommt...
Danach wird im Formular das insertcomponent gemacht...
Mit dem knopf wird zu einer IP außerhalb meiner Addresse connected...
hier sollte er nun in das event springen...

Macht er aber nicht...

Muss man was beachten, beim insertcomponent ?

MFG N3tw124rd
N3tw124rd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75


D5 Prof.
BeitragVerfasst: Do 31.07.03 09:46 
hi,
Ich nochmal hab noch weiter rum probiert...
habe herausgefunde das meine Componente im Components Array mit keinem Namen drin steht...
Dann habe ich einfach den Namen meiner Componente eingesetzt...

Geht aber immer noch nicht...

MFG N3tw124rd
neuling82 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Do 31.07.03 10:20 
ich habe das insert Komponent gar nicht verwendet, denn es handelt sich bei mir im eine nicht-visuelle Komponente. Der Timer ist ein Objekt in meinem Hauptobjekt, daher benötige ich diese Befehle nicht. Ich kenne mich mit diesen auch leider nicht aus!
N3tw124rd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75


D5 Prof.
BeitragVerfasst: Do 31.07.03 10:30 
Also bei mir ist die Komponente zwar eine visuelle komponente wird aber in einer unit created...
daher nicht visuelle...
sie steht auch in dem Component-array Components ...
mit ihrem Namen aber das event wird trotzdem nicht ausgelöst...

MFG N3tw124rd
RFZ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: Do 31.07.03 13:12 
Ich hab mittlerweile alles versucht :( Mit ner eigenen Klasse, mit diesem insertComponent, und nem haufen anderen schmarrn :(
Ich will nur diesen Quelltext möglichst ohne viel extras zum laufen bringen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
program TimerTest;
{$APPTYPE CONSOLE}
uses
  SysUtils, Windows, ExtCtrls, Classes;

var
 Timer: TTimer;

procedure TimerTimer(Sender: TObject);
begin
  WriteLn('bla');
end;

begin
  Timer := TTimer.Create(NIL);
  Timer.Interval := 200;
  Timer.OnTimer := TimerTimer; //[Fehler] Project1.dpr(17): Inkompatible Typen: Methodenzeiger und reguläre Prozedur
  Timer.Enabled := true;
  ReadLn;
end.


Ich hoffe jemand kennt die Lösung ....

cu RFZ


Zuletzt bearbeitet von RFZ am Do 31.07.03 14:06, insgesamt 1-mal bearbeitet
N3tw124rd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75


D5 Prof.
BeitragVerfasst: Do 31.07.03 13:15 
versuch es mal mit self und nicht mit NIL weil wenn du NIL machst beim create wird die kompo nicht in das ComponentArray übernommen... und dann kriegst du gar nix...

MFG N3tw124rd
RFZ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: Do 31.07.03 13:54 
es gibt kein self, da es kein übergeordnetes Objekt gibt, das ist ja schonmal mein erstes Problem...

cu RFZ