This post shows you how to get the color of the title bar for the active window. The method to get the color of the title bar of an active window in Delphi has changed over time.
In Windows 7 could get the color by using clActiveCaption but on WIndows 10 that no longer works but you can use the following code instead.
The title bar can have two colours fading from left to right.
I have provided function to get the left and right color and to determine if the right color is used or not
unit zzColorU; interface uses Vcl.Graphics; function zzGetWindowTitleBarPrimaryColor : TColor; // return the primary color of the title bar in active windows function zzGetWindowTitleBarSecondaryColor : TColor; // return the secondary (right hand side) gradiated color of the title bar in active windows function zzGetWindowTitleBarIsGradiated : boolean; // return TRUE if the color of title bars for active windows is gradiated implementation uses WinApi.Windows; // ================================= function zzGetWindowTitleBarPrimaryColor : TColor; // return the primary color of the title bar in active windows begin // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor result := WinApi.Windows.GetSysColor (WinApi.Windows.COLOR_ACTIVECAPTION) end; // ================================= function zzGetWindowTitleBarSecondaryColor : TColor; // return the secondary (right hand side) gradiated color of the title bar in active windows begin // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor result := WinApi.Windows.GetSysColor (WinApi.Windows.COLOR_GRADIENTACTIVECAPTION); end // ================================= function zzGetWindowTitleBarIsGradiated : boolean; // return TRUE if the color of title bars for active windows is gradiated var vUseGradient : boolean; begin result := FALSE; if (SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, @vUseGradient, 0)) then if (vUseGradient) then result := TRUE; end; // ================================= end.
About Me
- Oracle & Delphi software developer based in Perth, Western Australia
- Australian Delphi User Group – President and WA meeting organizer
- Australian Oracle User Group – WA State Committee Member
-
Available to do remote presentations to user groups on Delphi and Oracle topics
![]() |
![]() |
![]() |
Leave a Reply