Code: Select all
#WS_EX_LAYERED = $80000
Procedure SetWindowTransparency(hWnd.l, percent.b)
Protected alphaLevel.w, p.f
If percent < 0 Or percent > 100
ProcedureReturn
Else
p.f = percent / 100
alphaLevel = Int(p * 255)
EndIf
; next line sets window to layered extended style
; (so we can make it transparent!)
SetWindowLong_(hWnd, #GWL_EXSTYLE, #WS_EX_LAYERED)
; next line sets actual alpha level (can be between 0 and 255,
; 255 being fully visible or no transparency)
SetLayeredWindowAttributes_(hWnd, 0, alphaLevel, 2)
EndProcedure
