Delphi中,如何使用Png等透明格式图片还做 Form的形状
Raize_4.3.2组件包含有这样的控件,可以直接使用控件--RzFormShape
或者重新绘制:
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;
private
function CreateRegion(wMask: TBitmap; wColor: TColor;
hControl: THandle): HRGN;
function Tform1.CreateRegion(wMask:TBitmap;wColor:TColor;hControl:THandle): HRGN;
var
dc, dc_c: HDC;
rgn: HRGN;
x, y: integer;
coord: TPoint;
line: boolean;
color: TColor;
begin
dc := GetWindowDC(hControl); //取得窗口的DC
dc_c := CreateCompatibleDC(dc);
SelectObject(dc_c, wMask.Handle);
BeginPath(dc);//开始绘制
for x:=0 to wMask.Width-1 do //设定窗体的大小和形状
begin
line := false;
for y:=0 to wMask.Height-1 do
begin
color := GetPixel(dc_c, x, y);
if not (color = wColor) then
begin
if not line then
begin
line := true;
coord.x := x;
coord.y := y;
end;
end;
if (color = wColor) or (y=wMask.Height-1) then
begin
if line then
begin
line := false;
MoveToEx(dc, coord.x, coord.y, nil);
LineTo(dc, coord.x, y);
LineTo(dc, coord.x + 1, y);
LineTo(dc, coord.x + 1, coord.y);
CloseFigure(dc);
end;
end;
end;
end;
EndPath(dc);//结束绘制
rgn := PathToRegion(dc);
ReleaseDC(hControl, dc); //释放DC
Result := rgn;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
w1:TBitmap;
w2:TColor;
rgn: HRGN;
begin
w1:=TBitmap.Create;
w1.Assign(image1.Picture.Bitmap);//取得图片对象
w2:=w1.Canvas.Pixels[0,0];
rgn := CreateRegion(w1,w2,Handle);//生成窗体区域
if rgn<>0 then
begin
SetWindowRgn(Handle, rgn, true);//设定窗体形状
end;
w1.Free;
end;
Raize_4.3.2组件包含有这样的控件,可以直接使用控件--RzFormShape
D2007以前的,所谓的支持是假象,你可以设计在运行时直接加载png到Btn试试看.
至於设计时的支持,那是因为有PropertyEditor的处理,我估计属性编辑对png的图片做了转换,就这样而已
美国rz mask 效果如何
您好楼主很高兴为你解答:
美国rz mask运动口罩的确是比较不错的,就是价格有点小贵,一个口罩的价格就是198元左右。
鼻夹可调节,无束缚感,感觉不错。对于过滤效果,明显感觉无尘土颗粒进入。
素质回答,若有帮助,请及时【采纳】
~~~最好的满足就是给别人以满足~~~


- 相关评论
- 我要评论
-