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.

posted on 2010-12-31 10:46  巅枫  阅读(659)  评论(0编辑  收藏  举报