Learn more about GDI + [35]: tgppen-dotted brush displacement-setdashoffset

Source: Internet
Author: User
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, extctrls; Type tform1 = Class (tform) timer1: ttimer; Procedure formpaint (Sender: tobject); Procedure timer1timer (Sender: tobject); Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; var N: integer; Procedure tform1.formcreate (Sender: tobject); begin timer1.interval: = 100; end; Procedure destroy (Sender: tobject); var G: tgpgraphics; P: tgppen; begin G: = tgpgraphics. create (canvas. handle); P: = tgppen. create (aclchocolate, 8); p. setdashstyle (dashstyledashdotdot); p. setdashoffset (n); G. drawline (p, clientwidth Div 2, clientheight Div 2, 0, 0); G. drawline (p, clientwidth Div 2, clientheight Div 2, clientwidth Div 2, 0); G. drawline (p, clientwidth Div 2, clientheight Div 2, clientwidth, 0); G. drawline (p, clientwidth Div 2, clientheight Div 2, clientwidth, clientheight Div 2); G. drawline (p, clientwidth Div 2, clientheight Div 2, clientwidth, clientheight); G. drawline (p, clientwidth Div 2, clientheight Div 2, clientwidth Div 2, clientheight); G. drawline (p, clientwidth Div 2, clientheight Div 2, 0, clientheight); G. drawline (p, clientwidth Div 2, clientheight Div 2, 0, clientheight Div 2); Dec (n); if n> SQRT (sqr (clientwidth) + sqr (clientwidth )) then N: = 0; p. free; G. free; end; Procedure tform1.timer1timer (Sender: tobject); begin repaint; end.
 
   
 

Form file:

 
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 167 clientwidth = 242 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = pow.topcenter oncreate = formcreate onpaint = formpaint pixelsperinch = 96 textheight = 13 object timer1: ttimer ontimer = timer1timer left = 112 Top = 88 endend

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.