Autor Beitrag
sunshineh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: Do 16.10.08 17:48 
Kann ich in einer Procedure zur Laufzeit einen Timer erzeugen, dem ich einen String übergeben kann?
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 16.10.08 17:50 
Du willst einem Timer einen String übergeben? Kapier ich nicht, beschreib doch mal, was Du vorhast.
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Do 16.10.08 17:51 
Wahrscheinlich will er zur Laufzeit einen Timer erstellen und aus der Timer.ontimer-methode auf einen String zugreifen...
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 16.10.08 17:54 
Bleibt die Frage, wozu dynamisch.
sunshineh Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: Do 16.10.08 18:26 
Genau, ich möchte in der OnTimer-Funktion mit meinem übergebenen String arbeiten.
Dynamische Timererzeugung wäre schön (bin dann flexibler), muss aber nicht sein.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 16.10.08 18:41 
Das ist schon möglich.

[edit] Beispiel (komplette Unit):
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
    FTimer: TTimer;
    FString: string;
    procedure DoOnTimer(Sender: TObject);
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  FTimer := TTimer.Create(Self);
  FTimer.Interval := 1500;
  FTimer.OnTimer := DoOnTimer;
end;

procedure TForm1.DoOnTimer(Sender: TObject);
begin
  FString := FString + 'A';
  Label1.Caption := FString;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FTimer.Free;
end;

end.

[/edit]
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 16.10.08 20:49 
user profile iconsunshineh hat folgendes geschrieben Zum zitierten Posting springen:
Dynamische Timererzeugung wäre schön (bin dann flexibler), muss aber nicht sein.

Wenn du mehrere Timers mit ähnlichen Aufgaben brauchst, sind dynamische sinnvoller. Falls du nur einen benutzt, reicht auch ein über den Designer erstellter.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 16.10.08 21:09 
Hi,

Wobei sich bei 1000 Timern (a) die Frage stellt, ob das Konzept stimmt und (b), ob es nicht besser ist, eine sortierte Liste zu haben und einen Timer immer auf den frühesten Punkt zu stellen. Die Frage ist nur, in wieweit das Windows nicht sowieso macht :)

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)