本例效果图:


unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
    procedure Panel1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  f: Boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Self.Color := clWhite;
  Panel1.ParentBackground := False;
end;

procedure TForm1.Panel1Click(Sender: TObject);
var
  rgn: HRGN;
begin
  f := not f;
  if f then
    rgn := CreateEllipticRgn(0, 0, Panel1.Width, Panel1.Height)
  else
    rgn := CreateRectRgn(0, 0, Panel1.Width, Panel1.Height);

  SetWindowRgn(Panel1.Handle, rgn, True)
end;

end.

posted on 2008-05-01 11:24  万一  阅读(2994)  评论(0编辑  收藏  举报