Update Window Opacity Level - Delphi

Description

The maximum window opacity is 255, which represents full visibility. To make a window completely invisible, set the opacity to 0.

DarkCoderSc personal avatar
DarkCoderSc

Jean-Pierre LESUEUR

var ATargetWindow := FindWindow(nil, 'Untitled - Notepad');
if ATargetWindow = 0 then
    Exit();

var AOpacityLevel : Byte := 100; // 0 - 255 (High(Byte))

SetWindowLong(ATargetWindow, GWL_EXSTYLE, GetWindowLong(ATargetWindow, GWL_EXSTYLE) or WS_EX_LAYERED);

SetLayeredWindowAttributes(ATargetWindow, 0, AOpacityLevel, LWA_ALPHA);

Creating and researching code snippets takes time and effort. You’re welcome to share them through your own platforms, but please don’t forget to credit the original author, here: Jean-Pierre LESUEUR.


Created

April 24, 2025

Last Revised

April 24, 2025