{Fonctionne avec toutes les versions de Delphi}
//*************************à déclarer que pour les versions antérieurs à D7*********************
Const
LWA_ALPHA = $2;
GWL_EXSTYLE = (-20);
WS_EX_LAYERED = $80000;
WS_EX_TRANSPARENT = $20;
function SetLayeredWindowAttributes(Hwnd: THandle; crKey: COLORREF; bAlpha: Byte; dwFlags: DWORD):
Boolean; stdcall external 'user32.dll' name 'SetLayeredWindowAttributes';
//*************************************************************************************
Type
TValue = 0..100;
IMPLEMENTATION
{Gère la transparence d'une fenêtre}
procedure SetAlpha(hWnd: THandle; value: TValue);
begin
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd,GWL_EXSTYLE) or WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, (255 * (100 - value)) DIV 100, LWA_ALPHA);
end;
{Utilisation de : SetAlpha pour obtenir une transparence de 20%}
procedure TForm1.Button1Click(Sender: TObject);
begin
SetAlpha(Handle, 20);
end;