In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formpaint (Sender: tobject ); procedure formclick (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; var PC: pchar = 'hangzhou'; num: integer; Procedure tform1.formpaint (Sender: tobject); var G: tgpgraphics; B: tgpbrush; Font: tgpfont; begin G: = tgpgraphics. create (canvas. handle); B: = tgpsolidbrush. create (aclgoldenrod); Font: = tgpfont. create ('arial Black', 18, fontstyleregular); {parameter 2 indicates the number of output characters,-1 indicates all output} G. drawstring (PC, num, Font, makepoint (5.0, 5), B); B. free; font. free; G. free; end; Procedure tform1.formclick (Sender: tobject); var I, n: integer; begin n: = length (PC); num: = 0; for I: = 1 to n do begin num: = I; repaint; sleep (100); application. processmessages; end; num: =-1; for I: = 1 to length (PC) Do begin Inc (PC); repaint; sleep (100); application. processmessages; end; Dec (PC, n); end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 42 clientwidth = 501 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = pow.topcenter onclick = formclick onpaint = formpaint pixelsperinch = 96 textheight = 13end