请帮我看一下 实现 透明窗体的代码,编译后总有错误:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
SpeedButton1: TSpeedButton;
BitBtn1: TBitBtn;
OpenDialog1: TOpenDialog;
ColorDialog1: TColorDialog;
procedure Button1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
var
TranColor:tcolor;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
ColorDialog1.Color:=TranColor;
If ColorDialog1.Execute then
TranColor:=ColorDialog1.Color;
//选择要透明的颜色
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var
Bitmap:TBitMap;
begin
Bitmap:=TBitmap.Create;
If OpenDialog1.Execute then
begin
try
with Bitmap do begin
LoadFromFile(OpenDialog1.FileName);
//选择要透明的图片
Form1.Canvas.Draw(0,0,BitMap);
//显示未透明的图片
Transparent:=True;
TransParentColor:=TranColor;
//设定透明色
Form1.Canvas.Draw(280,0,BitMap);
//显示已透明图片
end;
finally
Bitmap.Free;
end;
end;
end;
end.
有高手请尽快给小弟解答,谢谢!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
SpeedButton1: TSpeedButton;
BitBtn1: TBitBtn;
OpenDialog1: TOpenDialog;
ColorDialog1: TColorDialog;
procedure Button1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
var
TranColor:tcolor;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
ColorDialog1.Color:=TranColor;
If ColorDialog1.Execute then
TranColor:=ColorDialog1.Color;
//选择要透明的颜色
end;procedure TForm1.BitBtn1Click(Sender: TObject);
var
Bitmap:TBitMap;
begin
Bitmap:=TBitmap.Create;
If OpenDialog1.Execute then
begin
try
with Bitmap do begin
LoadFromFile(OpenDialog1.FileName);
//选择要透明的图片
Form1.Canvas.Draw(0,0,BitMap);
//显示未透明的图片
Transparent:=True;
TransParentColor:=TranColor;
//设定透明色
Form1.Canvas.Draw(280,0,BitMap);
//显示已透明图片
end;
finally
Bitmap.Free;
end;
end;
end;
end.
有高手请尽快给小弟解答,谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货