随笔 - 2146  文章 - 97 评论 - 11765 trackbacks - 253

本例效果图:


unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormPaint(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses GDIPOBJ, GDIPAPI;

procedure TForm1.FormPaint(Sender: TObject);
const
  w = 100;
  h = 50;
var
  g: TGPGraphics;
  p: TGPPen;
  x,y: Single;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(0, 2);
  g.Clear(MakeColor(255,255,255));

  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));

  g.Free;
  p.Free;
end;

end.

posted on 2008-06-07 23:08 万一 阅读(...) 评论(...) 编辑 收藏