How to create a Typing Simulation in an about box (Views: 100)


In my about box, I'd like (when the about box window is shown) to start "typing" something (maybe in a paintbox). I mean, instead of showing some labels with the information, the program could start typing it by itself , maybe reading the information from an invisible memo on the same form and start writing it on the paintbox. For example, it could start writing letters one by one and making them sentences, also leave the spaces required and also show a graphic " | " after anything written (like in the edit controls). Could someone show some code of doing that? To better explain, I'd like to simulate the "typing" like someone is typing on the screen, leaving spaces, writing pauses, semicolons , etc.


A way would be to put a timer on the aboutbox, and every timer click draw add an extra character. It may be best to use a TImage and draw the chars to the image. That way they will stay without needing a redraw. Here are the basic steps:

Include the text to type in a memo.

On create move the memo off screen (make invisible), set variables of say ml=memo, line=0, sp=string, position=-1, Xpos:= 0, Ypos:= 0, tmpstr:= ''

On a timer do

  if (sp = -1) then
    ypos := ypos + image1.canvas.textheight('A');
    xpos := 0;
    tmpstr := memo1.lines[ml];
    sp := 1;
  Image1.Canvas.TextOut(xpos, ypos, tmpstr[sp]);
    xpos := xpos + image1.canvas.textwidth('A');
  if (sp > Length(TmpStr)) then
    sp := -1;

<< Back to main page