在windows2000下:<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br><br>const<br> WS_EX_LAYERED = $80000;<br> AC_SRC_OVER = $0;<br> AC_SRC_ALPHA = $1;<br> AC_SRC_NO_PREMULT_ALPHA = $1;<br> AC_SRC_NO_ALPHA = $2;<br> AC_DST_NO_PREMULT_ALPHA = $10;<br> AC_DST_NO_ALPHA = $20;<br> LWA_COLORKEY = $1;<br> LWA_ALPHA = $2;<br> ULW_COLORKEY = $1<br> ULW_ALPHA = $2<br> ULW_OPAQUE = $4<br><br>//新增加的常量定义<br><br>type<br> TForm1 = class(TForm)<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>function SetLayeredWindowAttributes(hwnd:HWND; crKey:Longint; <br> bAlpha:byte; dwFlags:longint ):longint; stdcall; external user32;//函数声明<br><br>var<br><br>Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var l:longint;<br>begin<br> l:=getWindowLong(Handle, GWL_EXSTYLE);<br> l := l Or WS_EX_LAYERED;<br> SetWindowLong (handle, GWL_EXSTYLE, l);<br> SetLayeredWindowAttributes (handle, 0, 180, LWA_ALPHA);<br>//第二个参数是指定透明颜色<br><br>//第二个参数为0则使用第四个参数设置alpha值,从0到255<br><br>end;<br><br>end.<br>