procedure TForm1.FormCreate(Sender: TObject);
var
hd:HRGN;
begin
hd:=CreateRoundRectRgn(0,0,Width,height,50,50);
SetWindowRgn(handle,hd,true);
end;
基本上不规则窗体,比如说你想做一个跟位图一样的窗体,
它的原理就是,通过对位图的每一个像素进行分析,
如果它的颜色不是位图里面你想去掉的背景色,
那么我们就把它通过CombineRgn加到窗体的Rgn.
然后SetWindowRgn(handle,hd,true);
我估计那些桌面精灵就是这么做的(个人观点).
还有个例子
procedure TForm1.FormCreate(Sender: TObject);
var
r1,r2,r3,r4,r5: hrgn;
begin
r1 := createellipticrgn(0,0,round(clientwidth / 2),clientheight);
r2 := createellipticrgn(round(clientwidth / 2),0,clientwidth,clientheight);
r3 := createellipticrgn(round(clientwidth / 4 ),round(clientheight / 4 *3),round(clientwidth / 4 *3),clientheight);
r4 := createrectrgn(0,0,0,0);
r5 := createrectrgn(0,0,0,0);
combinergn(r4,r2,r1,rgn_or);
combinergn(r5,r4,r3,rgn_or);
setwindowrgn(handle,r5,true);
deleteobject(r1);
deleteobject(r2);
deleteobject(r3);
deleteobject(r4);
deleteobject(r5);
end;
end.