📄 equalrgnu.pas
字号:
unit EqualRgnU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormPaint(Sender: TObject);
var
Region1, Region2: HRGN; // holds the regions to be compared
begin
{create an elliptical region}
Region1 := CreateEllipticRgn(50, 50, 150, 150);
{transform the region into a rectangular region. this function can be
performed on any pre-existing region}
SetRectRgn(Region1, 50, 50, 150, 150);
{create a rectangular region identical to Region1}
Region2 := CreateRectRgn(50, 50, 150, 150);
{paint both regions red}
Canvas.Brush.Color := clRed;
PaintRgn(Canvas.Handle, Region1);
PaintRgn(Canvas.Handle, Region2);
{indicate if the regions are identical}
if EqualRgn(Region1, Region2) then
Label1.Caption := 'Regions Equal'
else
Label1.Caption := 'Regions Not Equal';
{delete both regions as they are no longer needed}
DeleteObject(Region1);
DeleteObject(Region2);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -