uarc.pas

来自「DelphiWin32核心API参考光盘内容.是学习书籍中的源码,便于学习.」· PAS 代码 · 共 56 行

PAS
56
字号
unit UArc;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    PaintBox1: TPaintBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  iCount: Integer;    // a general loop control variable
  ArcBounds: TRect;   // the bounding rectangle of the arc
begin
  {initialize the bounding rectangle}
  ArcBounds := PaintBox1.BoundsRect;

  {initialize the pen used to draw the arcs}
  PaintBox1.Canvas.Pen.Width := 2;

  {draw 5 arcs}
  for iCount := 1 to 5 do
  begin
    {Draw the arc}
    Arc(PaintBox1.Canvas.Handle, ArcBounds.Left, ArcBounds.Top, ArcBounds.Right,
        ArcBounds.Bottom,ArcBounds.Right, (ArcBounds.Bottom-ArcBounds.Top)div 2,
        ArcBounds.Left, (ArcBounds.Bottom-ArcBounds.Top)div 2);

    {reduce the size of the bounding rectangle for the next arc}
    InflateRect(ArcBounds, -2, -2);

    {change the color of the pen used to draw the next arc}
    PaintBox1.Canvas.Pen.Color := PaletteIndex(iCount+10);
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?