Autor Beitrag
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 22.09.05 11:48 
kann mir jemand helfen ich möcjte ,das sich mein text in einem label von rechts nach links bewegt :roll:

kann mir da jemand helfen

oder geht das net :?:

Moderiert von user profile iconTino: Größschreibung im Titel aktiviert.
kde2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Do 22.09.05 12:15 
Hallo!


Es geht.
Du braust einen Timer und ein Label.
Timer Interval auf 60. (Je nach belieben)

hier ist der Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
text:String;

procedure TForm1.FormCreate(Sender: TObject);
begin
text:='ich kann alles!';
label1.caption:=text;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var s:string;
begin
if length(Label1.Caption)>=60 then begin
s:=Copy(label1.Caption,60,1);
Label1.Caption:=s  +Copy(Label1.Caption,1,59);

end else Label1.Caption:=' ' +Label1.Caption;
end;




Gruß Konstantin

ps: 60 ist die Länge des Textes bzw. sagt aus wie lange der Text im Label laufen soll bevor er wiederhohlt wird. [beim ändern von 60,solltest du 59 durch den 'neuen Wert'-1 ersetzen]

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
kde2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Do 22.09.05 12:42 
Ich habe gerade gelesen, dass du willst dass der Text von Rechts nach Links und nicht umgekehrt laufen soll:


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:
27:
text:String;
textlength:integer;

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
text:='ich kann alles!';
textlength:=length(text);
//fühlt mit Leerzeichen Da es ja von rechts nach links laufen soll
for I := 1 to 60-textlength do begin    // Iterate
   text:=' ' + text;
end;    // for

label1.caption:=text;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var s:string;
begin
if Label1.Caption[1] <> ' ' then begin
s:=Copy(label1.Caption,1,1);
Label1.Caption:=Copy(Label1.Caption,2,59)+s;

end else Label1.Caption:=Copy(Label1.Caption,2,Length(Label1.Caption)-1)
+' ';
end;



Natürlich kann man den Code noch kompakter machen. In diesem Fall sollte die Absicht verständlich werden.

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 22.09.05 13:02 
ok danke und wo muss ich das dan einfügen
oder reinsetzen
kde2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Do 22.09.05 13:08 
das hier in Variablendeklaration der Unit(Formulars):
ausblenden Delphi-Quelltext
1:
2:
text:String;
textlength:integer;


das ist Form.Create Event:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
text:='ich kann alles!';
textlength:=length(text);
//fühlt mit Leerzeichen Da es ja von rechts nach links laufen soll
for I := 1 to 60-textlength do begin    // Iterate
   text:=' ' + text;
end;    // for


und das ist im Timer.Tick Event

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Timer1Timer(Sender: TObject);
var s:string;
begin
if Label1.Caption[1] <> ' ' then begin
s:=Copy(label1.Caption,1,1);
Label1.Caption:=Copy(Label1.Caption,2,59)+s;

end else Label1.Caption:=Copy(Label1.Caption,2,Length(Label1.Caption)-1)
+' ';
end;
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 22.09.05 14:57 
das ist Form.Create Event:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
text:='ich kann alles!';
textlength:=length(text);
//fühlt mit Leerzeichen Da es ja von rechts nach links laufen soll
for I := 1 to 60-textlength do begin    // Iterate
   text:=' ' + text;
end;    // for


was bedeutet formCreat ich wollt das in en panel setzten
kde2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Do 22.09.05 15:06 
Wenn du auf dein Formular einen Doppelklick(bei der Entwicklung) machst, kommst du in den Codeeditor. Dein IDE(Delphi 5,6,7,8,9) erzeugt dir schon eine Procedure(Methode) namens Create. Diese Procedure wird ausgeführt wenn du dein Programm startest und dein Formular erzeugt wird. Natürlich kannst du den Code den ich jetzt in Create Methode reinkopiert habe wo anders erzeugen. Nur muss dieser Code ausgeführt werden bevor dein Timer den anderen Code zum ersten Mal ausführt.
kde2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45


D5 Pro,D2k5 PE
BeitragVerfasst: Do 22.09.05 15:11 
am besten du schaust dir dieses hier an(fallst du in delphi nicht so fit bist):
dsdt.info/grundlagen/sprache/
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 22.09.05 15:51 
@KDE: Bitte vermeide Doppelposts und benutze den Edit-Button. Danke.

@chriss: Ich kann dir auch sehr den Crashkurs von Christian empfehlen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)