Learn more about GDI + [4]: drawellipse-draw an ellipse

Source: Internet
Author: User
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 formcreate (Sender: tobject); Procedure formdestroy (Sender: tobject); Procedure formmousedown (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer ); procedure formmousemove (Sender: tobject; shift: tshiftstate; X, Y: integer); Procedure formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer ); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; var X: integer = 20; Y: integer = 20; W: integer = 100; H: integer = 50; F: byte; A, B: integer; P: tgppen; Procedure tform1.formcreate (Sender: tobject); begin P: = tgppen. create (makecolor (255, 0, 0), 2); end; Procedure tform1.formdestroy (Sender: tobject); begin p. free; end; Procedure tform1.formmousedown (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); begin F: = 1; A: = x; B: = y; end; Procedure tform1.formmousemove (Sender: tobject; shift: tshiftstate; X, Y: integer); begin if (F = 0) Then exit; if ssctrl in shift then begin F: = 2; text: = 'ctrl: Press, the mouse can resize '; end else text: =' No ctrl key pressed, the mouse can adjust the position '; A: = x-A; B: = Y-B; repaint; A: = x; B: = y; end; Procedure tform1.formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); begin F: = 0; end; Procedure tform1.formpaint (Sender: tobject); var G: tgpgraphics; begin G: = tgpgraphics. create (canvas. handle); G. clear (makecolor (255,255,255); Case F of 1: Begin Inc (X, A); Inc (Y, B); end; 2: Begin Inc (W, ); INC (H, B); end; G. drawellipse (p, X, Y, W, H); G. free; end.
 
   
 

Form file:

 
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 176 clientwidth = 337 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = podesktopcenter oncreate = formcreate ondestroy = formdestroy onmousedown = formmousedown onmousemove = formmousemove onmouseup = formmouseup onpaint = formpaint placement = 96 textheight

  

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.