我在书上看到:程序代码:
1、新建一个delphi 项目
2、在窗体上添加一个speedbutton,一个bitBtn,一个Button,并分别将其captition改成 :透明颜色、选择图片、退出。
3、在窗体添加一个Opendialog和Colordialog控件,并将窗体的BorderStyle属性设置为:bsNone.
4 添加一个全程变量Trancolor,用来保存需要透明的颜色。
(我应该在什么位置添加全程变量Trancolor?如何添加?)
5、编写代码,选择透明颜色
procedure TForm1.SpeedButton1Click(sender:TObject);
begin
 ColorDialog1.Color:=TranColor;
 if colorDialog1.Execute then
 TranColor:=ColorDialog1.Color;
 //选择要透明的颜色
 end;
6、编写代码,选择要透明的窗体,并保存窗体的两侧显示出来。
procedure TForm1.BitBtn1Click(sender:TObject);
  var
  Bitmap:TBitmap;
  begin
  Bitmap:=TBitMap.create;
  if Opendialog1.execute then
  begin
   try
    with BitMap do begin
    LoadFormFile(Opendialog1.FileName);
    //选择要透明的图片
    Form1.Canvas.Draw(0,0,BitMap);
    //显示未透明的图片
    Transparent:=Ture;
    TransparentColor:=TranColor;
    //设定透明颜色
    Form1.Canvas.Draw(280,0,BitMap);
    end;
    finally
    BitMap.FreeImage;
    end;
    end;
    end;
7、编写代码,设置退出按钮。
procedure TForm1.Button1Click(sender:TObject);begin
     Form1.close;end; 如何添加全程变量在 uses 还是 var 里,该如何添加?