首页 > 创建异形窗口[5]

创建异形窗口[5]

本例效果图:



o_84307.gif
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;procedure FormCreate(Sender: TObject);procedure FormPaint(Sender: TObject);procedure Button1Click(Sender: TObject);procedure FormDblClick(Sender: TObject);procedure FormDestroy(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}varbit: TBitmap;procedure TForm1.FormCreate(Sender: TObject);
beginbit := TBitmap.Create;bit.LoadFromFile('c:	emp	est.bmp');
end;procedure TForm1.FormPaint(Sender: TObject);
beginCanvas.Draw(0, 0, bit);
end;procedure TForm1.Button1Click(Sender: TObject);
varrgn1,rgn2: HRGN;x,y,w,h: Integer;
beginw := bit.Width;h := bit.Height;rgn1 := CreateRectRgn(0, 0, w, h);for x := 0 to w - 1 dofor y := 0 to h - 1 doif bit.Canvas.Pixels[x,y] = clBlack thenbeginrgn2 := CreateRectRgn(x, y, x+1, y+1);CombineRgn(rgn1, rgn1, rgn2, RGN_XOR);DeleteObject(rgn2);end;SetWindowRgn(Handle, rgn1, True);Self.BorderStyle := bsNone;Self.Width := w;Self.Height := h;
end;procedure TForm1.FormDblClick(Sender: TObject);
beginClose;
end;procedure TForm1.FormDestroy(Sender: TObject);
beginbit.Free;
end;end.

更多相关:

  • 开发日常的Silverlight应用程序时,常常要对一个域多个控件实现可拖放的MOUSE操作,在Silverlight中实现拖放的功能其实非常简单,但是为了提高程序功能代码的可复用性,程序员常常喜欢把常用的代码封装成一个工具类,例如Asp.net中常用SQLHelper类,用来操作数据库的,这里我们介绍的类是在Silverlight中...