unit1.pas
来自「delphi编程实效百例的随书源代码 这是其中的界面外观部分」· PAS 代码 · 共 75 行
PAS
75 行
unit Unit1;
interface
uses
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.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?