type TSetLayeredWindowAttributes = function (hwnd:HWND; crKey:Longint; bAlpha:byte; dwFlags:longint ):longint; stdcall;var Form1: TForm1; SetLayeredWindowAttributes: TSetLayeredWindowAttributes = nil;...procedure InitProcs; const sUser32 = 'User32.dll'; var ModH: HMODULE; begin ModH := GetModuleHandle(sUser32); if ModH <> 0 then @SetLayeredWindowAttributes := GetProcAddress(ModH, 'SetLayeredWindowAttributes'); end;procedure TForm1.FormCreate(Sender: TObject); var AStyle:Integer; begin InitProcs; Alpha:=150;//0为完全透明,255完全不透明 AStyle := GetWindowLong(Handle, GWL_EXSTYLE); if (AStyle and $00080000) = 0 then SetWindowLong(Handle, GWL_EXSTYLE, AStyle or $00080000); if assigned(SetLayeredWindowAttributes) then SetLayeredWindowAttributes(Handle,0,Alpha,$2); end;
TSetLayeredWindowAttributes = function (hwnd:HWND; crKey:Longint; bAlpha:byte; dwFlags:longint ):longint; stdcall;var
Form1: TForm1;
SetLayeredWindowAttributes: TSetLayeredWindowAttributes = nil;...procedure InitProcs;
const
sUser32 = 'User32.dll';
var
ModH: HMODULE;
begin
ModH := GetModuleHandle(sUser32);
if ModH <> 0 then
@SetLayeredWindowAttributes := GetProcAddress(ModH, 'SetLayeredWindowAttributes');
end;procedure TForm1.FormCreate(Sender: TObject);
var AStyle:Integer;
begin
InitProcs;
Alpha:=150;//0为完全透明,255完全不透明
AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if (AStyle and $00080000) = 0 then
SetWindowLong(Handle, GWL_EXSTYLE, AStyle or $00080000);
if assigned(SetLayeredWindowAttributes) then
SetLayeredWindowAttributes(Handle,0,Alpha,$2);
end;
还没有定义变量呢!