HRGN CreatePolygonRgn( CONST POINT*lppt,//pointer to array of points int cPoints,//number of points in array int fnPolyFillMode//polygon-filling mode ); 以上为SetWindowPos函数的原型
试了一下,在窗体好象没问题,但在frame中重写了一下Create方法 var hrgn:Longint; begin hrgn:=CreateRoundRectRgn(0,0,100,100,100,100); SetWindowRgn(Self.Handle,hrgn,true);但有时出现问题,关注中
在Form中可以根据图片来实现不规则宿窗体, frame可不可以用图片来实现?
想用图片来实现不规则的Frame!
Ctrl+C --> Ctr+Vfunction GraphicToRGN(mGraphic: TGraphic; mTransPoint: TPoint): HRGN; var I, J: Integer; vStart: Integer; vHandle: HRGN; vTransColor: TColor; begin Result := 0; if not Assigned(mGraphic) then Exit; Result := CreateRectRgn(0, 0, 0, 0); with TBitmap.Create do try Width := mGraphic.Width; Height := mGraphic.Height; Canvas.Draw(0, 0, mGraphic); vTransColor := Canvas.Pixels[mTransPoint.X, mTransPoint.Y]; for I := 0 to Height - 1 do begin vStart := 0; for J := 0 to Width do begin if (Canvas.Pixels[J, I] <> vTransColor) and (J < Width) then if vStart < 0 then vStart := J else else if vStart >= 0 then begin vHandle := CreateRectRgn(vStart, I, J, I + 1); try CombineRgn(Result, Result, vHandle, RGN_OR); finally DeleteObject(vHandle); end; vStart := -1; end; end; end; finally Free; end; end; { GraphicToRGN } procedure TForm1.BitBtn1Click(Sender: TObject); var vRGN: HRGN; Frame : TFrame1; begin //BorderStyle := bsNone; Image1.Left := 0; Image1.top := 0; Frame := TFrame1.Create(Application); Frame.Parent := Application.MainForm; Frame.Show; vRGN := GraphicToRGN(Image1.Picture.Graphic, Point(0, 0)); try SetWindowRgn(Frame.Handle, vRGN, True); finally DeleteObject(vRGN); end; end;
可以响窗体绘制事件,在TForm1.FormPaint()过程中调用CanVas.Polyline绘制窗体轮廓线
程序结束之前利用SetWindowPos函数回复窗体正常的位置和显示属性。
CONST POINT*lppt,//pointer to array of points
int cPoints,//number of points in array
int fnPolyFillMode//polygon-filling mode
);
以上为SetWindowPos函数的原型
关注中...
var
kaikai:HRGN;
begin
panel1.Color:=clRed;
kaikai:=CreateEllipticRgn(0,0,400,400); {Left,Top,Width ,Height}
SetWindowRgn(panel1.Handle,kaikai, True);
DeleteObject(kaikai);
end;
1.CreateRectRgn:建立矩形区域
2.CreateRoundRectRgn:建立圆角矩形区域
3.CreateEllipticRgn:建立圆形区域
4.CreatePolygonRgn:建立多边形区域
5.PtInRegion:判断鼠标位置是否位于某一区域内
6.CombineRgn:复合区域
另外:
在Form1.creat事件中,加入如下代码:
form1.canvas.brush:=clear;
form1.bordstyle:= none;//可能有点出入
你在窗体上用一image装载你要的任何画面,设置为透明!你就能得到任意窗体了,当然你现在得到的还只是简单的窗体外型,要想移动窗体,那就要重载form的createparams方法
var
hrgn:Longint;
begin
hrgn:=CreateRoundRectRgn(0,0,100,100,100,100);
SetWindowRgn(Self.Handle,hrgn,true);但有时出现问题,关注中
frame可不可以用图片来实现?
Ctrl+C --> Ctr+Vfunction GraphicToRGN(mGraphic: TGraphic; mTransPoint: TPoint): HRGN;
var
I, J: Integer;
vStart: Integer;
vHandle: HRGN;
vTransColor: TColor;
begin
Result := 0;
if not Assigned(mGraphic) then Exit;
Result := CreateRectRgn(0, 0, 0, 0);
with TBitmap.Create do try
Width := mGraphic.Width;
Height := mGraphic.Height;
Canvas.Draw(0, 0, mGraphic);
vTransColor := Canvas.Pixels[mTransPoint.X, mTransPoint.Y];
for I := 0 to Height - 1 do begin
vStart := 0;
for J := 0 to Width do begin
if (Canvas.Pixels[J, I] <> vTransColor) and (J < Width) then
if vStart < 0 then
vStart := J
else
else if vStart >= 0 then begin
vHandle := CreateRectRgn(vStart, I, J, I + 1);
try
CombineRgn(Result, Result, vHandle, RGN_OR);
finally
DeleteObject(vHandle);
end;
vStart := -1;
end;
end;
end;
finally
Free;
end;
end; { GraphicToRGN }
procedure TForm1.BitBtn1Click(Sender: TObject);
var
vRGN: HRGN;
Frame : TFrame1;
begin
//BorderStyle := bsNone;
Image1.Left := 0;
Image1.top := 0;
Frame := TFrame1.Create(Application);
Frame.Parent := Application.MainForm;
Frame.Show;
vRGN := GraphicToRGN(Image1.Picture.Graphic, Point(0, 0));
try
SetWindowRgn(Frame.Handle, vRGN, True);
finally
DeleteObject(vRGN);
end;
end;
http://topic.csdn.net/t/20040424/13/3003230.html
http://topic.csdn.net/t/20010427/09/106695.html