本例效果图:


unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    procedure FormCreate(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  pt: TPoint;
  RGN_Mode: Integer = RGN_AND;

procedure TForm1.FormCreate(Sender: TObject);
begin
  pt.X := Width;
  pt.Y := Height;
  RadioGroup1.Items.CommaText := 'RGN_AND,RGN_OR,RGN_XOR,RGN_DIFF,RGN_COPY';
  RadioGroup1.ItemIndex := 0;
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  RGN_Mode := RadioGroup1.ItemIndex + 1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  rgn1,rgn2: HRGN;
begin
  rgn1 := CreateEllipticRgn(10,10,110,110);
  rgn2 := CreateEllipticRgn(80,10,180,110);
  CombineRgn(rgn1, rgn1, rgn2, RGN_Mode);
  SetWindowRgn(Handle, rgn1, True);
end;

procedure TForm1.FormDblClick(Sender: TObject);
var
  rgn: HRGN;
begin
  rgn := CreateRectRgn(0, 0, pt.X, pt.Y);
  SetWindowRgn(Handle, rgn, True);
end;

end.

posted on 2008-04-30 21:39  万一  阅读(3126)  评论(2编辑  收藏  举报