Einzelnen Beitrag anzeigen

Benutzerbild von APP
APP

Registriert seit: 24. Feb 2003
Ort: Graz (A)
705 Beiträge
 
Delphi 7 Enterprise
 
#7

Re: Events bei Konsole-application?

  Alt 6. Sep 2003, 18:47
Hallo Illuminator-23-5,

Dein anfangs geposteter Code compiliert bei meinem D5 pro zu Hause gar
nicht, mich hat Dein Problem aber interessiert, ich habe folgendes in
einer NG gefunden:

Delphi-Quellcode:
(*$apptype console*)
Program timer;
Uses sysUtils, forms, windows, extCtrls;

(*Demos console app using timer.*)

Var
    qDone: boolean = false;

Type
    ToTimerHandler = class(Tobject)
        constructor create (nMs: integer);
        private
        FoT: Ttimer;
        procedure timerCall(o: Tobject);
        end;

Constructor ToTimerHandler.create(nMs: integer);
Begin
    inherited create;
    Fot := Ttimer.create(application);
    Fot.interval := nMs;
    Fot.onTimer := timerCall;
    Fot.enabled := true;
End;


Procedure ToTimerHandler.timerCall(o: Tobject);
Begin
    FoT.enabled := false;
    writeln;
    writeln;
    write ('Hi there! ...Tell me something ...');
    readln;
    writeln;
    writeln ('Oh my God! You hit Enter? We''re done for!');
    sleep(1000);
    qDone := true;
End;

Var
    oT: ToTimerHandler;
Begin
    oT := ToTimerHandler.create(5000);
    while not qDone do application.processMessages;
    oT.free;
    application.terminate;
End.
Autor: PhilippeRanger@compuserve.remove-this.com

Ich hoffe es hilft Dir weiter...
Armin P. Pressler

BEGIN
...real programmers are using C/C++ - smart developers Delphi;
END;
  Mit Zitat antworten Zitat