欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

再学 GDI+[3]: DrawRectangle - 绘制矩形

程序员文章站 2022-03-31 11:29:31
...

 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormPaint(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
uses
  GDIPOBJ,GDIPAPI;
procedure TForm1.FormPaint(Sender: TObject);
var
  g:TGPGraphics;
  p:TGPPen;
  x,y:Single;
const
  w = 100;
  h = 50;
begin
  g:=TGPGraphics.Create(Canvas.Handle);
  g.Clear(aclWhite);
  p:=TGPPen.Create(0,2);

  x:=20;
  y:=20;

  p.SetColor(aclRed);
  g.DrawRectangle(p,x,y,w,h);

  p.SetColor(aclGold);
  x:=x + w/2;
  y:=y + h/2;
  g.DrawRectangle(p,MakeRect(x,y,w,h));

  p.Free;
  g.Free;
end;

end.

转载于:https://www.cnblogs.com/keyvip/archive/2010/12/31/1922789.html