Autor Beitrag
No0B
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Mi 21.04.10 21:12 
Hallo zusammen, habe bei meinem Prog ein Label mit Text auf der Form 4. Wird Form 4 geöffnet läuft der Text von unten nach oben dauerhaft durch.

Der Text soll aber auf dem Label oben anfangen erst ca 1-2 sek stehenbleiben und dann anfangen zu laufen.

Hoffe ihr wisst was ich meine. Wie bekomme ich das hin ? Mit sleep, wait ?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 21.04.10 22:26 
Wie lässt du es denn von oben nach unten laufen? Über einen Timer?

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Do 22.04.10 20:43 
Ja mit nem Timer.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm4.Timer1Timer(Sender: TObject);
begin
 if Label1.Top < - Label1.Height then 

     Label1.Top := Form4.Height
  else
     Label1.Top := Label1.top  - 1 
end;
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 22.04.10 20:51 
hi :)

Da gibt es mehrere Möglichkeiten. Ich würde es wohl so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
type
  TForm1: TForm
  {..}
  procedure Timer1Timer(Sender: TObject);
  private
    procedure Textlauf(Sender: TObject);
  end;

implementation

{..}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Interval := 1000;
  Timer1.OnTimer := self.Textlauf;
end;

end;

Dabei ist der Timer zuerst für die Wartezeit zuständig, dann bekommt er ein neues Intervall und reguliert den Textfluss.
Eine andere Möglichkeit wäre, ständig eine if-Abfrage durchzuführen, ob die Startzeit vorbei ist. Würde ich nicht machen :nixweiss:

lg,

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Do 22.04.10 21:36 
Kann ich nicht in den vorhandenen Code ne Wartefunktion einbauen ?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 22.04.10 21:48 
Hi :)

Textlauf wäre dein schon vorhandener Code. Also musst du wirklich nur etwas hinzufügen, du kannst alles, was du schon hast, behalten.

lg,

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 23.04.10 19:39 
Wie soll ich meinen Text in den Code einfügen ? Timer1.OnTimer := self.Textlauf;

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:
unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
   procedure Textlauf(Sender: TObject);
  public
    {}
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);
begin
   Label1.Caption := 'Hallo'#13#10'Welt';
end;


procedure TForm4.Timer1Timer(Sender: TObject);
begin
 Timer1.Interval := 1000;
 Timer1.OnTimer := self

 if Label1.Top < - Label1.Height then 

     Label1.Top := Form4.Height
  else
     Label1.Top := Label1.top  - 1 ; 
end;

end.
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: Fr 23.04.10 19:50 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm4.FormCreate(Sender: TObject);
begin
   Label1.Caption := 'Hallo'#13#10'Welt';
   Timer1.Interval:=2000//2sec bevor das erste mal ausgelöst wird
   Timer1.Enabled:=True; //timer anschalten
end;


procedure TForm4.Timer1Timer(Sender: TObject);
begin
 Timer1.Interval := 1000;

 if Label1.Top < - Label1.Height then 

     Label1.Top := Form4.Height
  else
     Label1.Top := Label1.top  - 1 ; 
end;


Das sollte schon reichen. Im Objektinspektor den Timer.Enabled:=False setzen, damit er erst nach dem Create losläuft.

_________________
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)
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 23.04.10 19:56 
user profile iconNo0B hat folgendes geschrieben Zum zitierten Posting springen:
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:
unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
   procedure Textlauf(Sender: TObject);
  public
    {}
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);
begin
   Label1.Caption := 'Hallo'#13#10'Welt';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Interval := 1000;
  Timer1.OnTimer := self.Textlauf;
end;


procedure TForm4.(*Timer1Timer*)Textlauf(Sender: TObject);
begin
 (*Timer1.Interval := 1000;
 Timer1.OnTimer := self*)


 if Label1.Top < - Label1.Height then 

     Label1.Top := Form4.Height
  else
     Label1.Top := Label1.top  - 1 ; 

end;

end.


E: Die Lösung von @Xion ist auch gut möglich, wenn bei Ablauf des ersten Timers nichts besonderes mehr geschehen soll.

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 23.04.10 20:04 
Ja geht, interval bisschen runtergeschraubt und es läuft flüssig.

Und wie bekomme ich das hin das der Text am oberen rand anfägnt zu laufen
wenn ich form 4 zu mache und wieder öffne ?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 23.04.10 20:06 
Hi :)

Die Notification-Methode dazu heißt TForm.OnShow.

lg,

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 23.04.10 20:17 
Das heisst ?

Sorry für die fragerei, bin absolut neu was Delphi angeht.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 23.04.10 20:23 
Hi :)

Um im Timer die OnTimer-Methode zu implementieren, hast du ja im Object Inspector des Timers unter Events\OnTimer einen Doppelklick gemacht.
Um für dein Formular eine OnTimer-Methode zu implementieren, musst du im Object Inspector des Formulars unter Events\OnShow einen Doppelklick machen. In der dann deklarierten Methode kannst du Quelltext einfügen, der bei jedem erneuten Anzeigen des Formulars ausgeführt wird.

lg,

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 23.04.10 20:59 
Irgend ne Idee ?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 23.04.10 21:11 
Wo liegt denn jetzt ncoh das Problem? :zwinker: Verstehst du einen Teil noch nicht, den ich vielleicht etwas großschrittig beschrieben habe? :)

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 23.04.10 21:26 
Nix verstehen, was schreibe ich in onshow ?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 23.04.10 21:33 
Hi :)

Na, dem Label sagen, es soll wieder an seine Startposition zurück - Label1.Top := ..

PS: Ist
Zitat:
Und wie bekomme ich das hin das der Text am oberen rand anfägnt zu laufen
wenn ich form 4 zu mache und wieder öffne ?
ein Tippfehler(Freud'scher), oder warum soll es jetzt anders herum geschehen als es im Moment in deinem Quelltext steht? :)

Dazu denn entsprechend Label1.Top := -Label1.Height; Dann ist das Label um seine Höhe über dem oberen Formularrand, der Text käme dann allerdings glaube ich falschrum ;)

_________________
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)
No0B Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 62



BeitragVerfasst: Fr 23.04.10 21:41 
Hast recht, kommt von unten. Aber so weit so gut :zustimm:

bis zum nächsten Prob :wink: