was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

40 Visitors Online


 
...Text wie mit einer Schreibmaschine getippt anzeigen (horizontal oder vertikal)?
Autor: Christian Poljac
Homepage: http://www.big-x.cjb.net
[ Tip ausdrucken ]  

Tip Bewertung (13):  
     


{
 To make this code to work you would need 2 images,
 one for the horizontal- and another for the vertical text.
}

// VerticalTypewriter ( <Text>, <Image to write to>, <Time to delay between every chars> )
procedure VerticalTypewriter(text: string; image: timage; delay: integer);
var
 
x,y,i: integer;
begin
 
image.Canvas.Refresh;
 application.ProcessMessages;
 y := 1;

 for i := 1 to length(text) do begin
  
application.ProcessMessages;
  y := y+image.Canvas.TextHeight(text[i]);
  x := image.width div 2 - (image.Canvas.TextWidth(text[i]) div 2);
  image.Canvas.TextOut(x,y,text[i]);
  sleep(delay);
 end;

end;

// Horizontal Typewriter ( <Text>, <Image to write to>, <Time to delay between every chars>, <Space between chars>)
procedure HorizontalTypewriter(text: string; image: timage; delay, space: integer);
var
 
x,y,i: integer;
begin
 
image.Canvas.Refresh;
 application.ProcessMessages;
 x := 1;

 for i := 1 to length(text) do begin
  
application.ProcessMessages;
  y := image.Picture.Height div 2 - (image.Canvas.TextHeight(text[i]) div 2);
  x := x+image.Canvas.TextWidth(text[i])+space;
  image.Canvas.TextOut(x,y,text[i]);
  sleep(delay);
 end;

end;


// Sample calls:
procedure TForm1.Button1Click(Sender: TObject);
begin
 
//                  <text>          <image>  <delay>
 
VerticalTypewriter('HELLO BIG-X',   image1,  100     );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 
//                    <text>         <image>  <delay>  <space>
 
HorizontalTypewriter('Hello Big-X',  image2,  100,     1       );
end;




 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners