Procedure Transparan(pencere: HWND; deger:integer);
var //POWERED BY KAMIL YESIL
FColorKey: TCOLOR;
{} function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean;
type //POWERED BY KAMIL YESIL
TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte;
dwFlags: Longint): Longint;
stdcall;
const
LWA_ALPHA = 2;
WS_EX_LAYERED = $80000;
var hUser32: HMODULE;
SetLayeredWindowAttributes: TSetLayeredWindowAttributes;
begin
Result := False;
hUser32 := GetModuleHandle('USER32.DLL');
if hUser32 <> 0 then
begin @SetLayeredWindowAttributes := GetProcAddress(hUser32, 'SetLayeredWindowAttributes');
if @SetLayeredWindowAttributes <> nil then
begin
SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) or WS_EX_LAYERED);
SetLayeredWindowAttributes(Wnd, 0, Trunc((255 / 100) * (100 - nAlpha)), LWA_ALPHA);
Result := True;
end;
end;
end;
BEGIN //temel
SetWindowLong(pencere, GWL_EXSTYLE, GetWindowLong(pencere, GWL_EXSTYLE) or WS_EX_LAYERED);
SetLayeredWindowAttributes(pencere, ColorToRGB(FColorKey), Deger, LWA_ALPHA);
END;//temel //POWERED BY KAMIL YESIL
kullanımı:
//forma bir trackbar ekleyin
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
Transparan(handle,trackbar1.Position);
end;