您现在的位置:首页 >> 图形媒体 >> 图形媒体 >> 内容

CopyRect函数实例

时间:2011/9/3 15:02:02 点击:

  核心提示:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,...
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
PaintBox1: TPaintBox;
PaintBox2: TPaintBox;
Button1: TButton;
procedure PaintBox1Paint(Sender: TObject);
procedure PaintBox2Paint(Sender: TObject);
procedure Button1Click(Sender: TObject);
end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  PaintBox1.Canvas.Brush.Color := clWhite;
  PaintBox1.Canvas.FillRect(PaintBox1.BoundsRect);
  PaintBox1.Canvas.MoveTo(0, 0);
  PaintBox1.Canvas.LineTo(PaintBox1.Width, PaintBox1.Height);
  PaintBox1.Canvas.MoveTo(PaintBox1.Width, 0);
  PaintBox1.Canvas.LineTo(0, PaintBox1.Height);
end;
procedure TForm1.PaintBox2Paint(Sender: TObject);
begin
  PaintBox2.Canvas.Brush.Color := clGreen;
  PaintBox2.Canvas.Ellipse(0, 0, PaintBox2.Width, PaintBox2.Height);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
  R1,R2: TRect;
begin
  R2 := PaintBox2.BoundsRect;
  {Windows.CopyRect}
  CopyRect(R1, R2); //相当于: R1 := R2;

  OffsetRect(R1, 10, 10);
  {TCanvas.CopyRect}
  PaintBox1.Canvas.CopyRect(R1, PaintBox2.Canvas, R2);
end;
end.

Tags:函数 实例 
作者:站长 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2022 版权所有 All Rights Reserved.
  • 沪ICP备05001939号