创建异形窗口[2]

创建异形窗口[2]

本例效果图:

创建异形窗口[2]
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Button1.Caption := '创建';
end;

procedure TForm1.Button1Click(Sender: TObject);
const
  pts: array[0..3] of TPoint = (
    (x:10; y:40),
    (x:46; y:120),
    (x:82; y:40),
    (x:46; y:10)
  );
var
  rgn: HRGN;
begin
  rgn := CreatePolygonRgn(pts, Length(pts), 1); {1:ALTERNATE; 2:WINDING}
  SetWindowRgn(Handle, rgn, True);
end;

procedure TForm1.FormDblClick(Sender: TObject);
begin
  Close;
end;

end.
posted on 2008-04-30 16:59  万一  阅读(2997)  评论(0)  编辑  收藏
上一篇:创建异形窗口[5]


下一篇:创建异形窗口[6]