Change window title bar colour
(macOS only)
For macOS 10.10 and later, the following code may be used to change the colour of a window's title bar.
{$modeswitch objectivec2}
interface
uses
CocoaAll,
...;
const
NSWindowTitleVisible = 0;
NSWindowTitleHidden = 1;
type
NSWindowTitleVisibility = NSInteger;
NSWindowGlam = objccategory external (NSWindow)
function titleVisibility: NSWindowTitleVisibility; message 'titleVisibility';
procedure setTitleVisibility(AVisibility: NSWindowTitleVisibility); message 'setTitleVisibility:';
function titlebarAppearsTransparent: Boolean; message 'titlebarAppearsTransparent';
procedure setTitlebarAppearsTransparent(AFlag: Boolean); message 'setTitlebarAppearsTransparent:';
end;
{ TForm1 }
procedure TForm1.FormShow(Sender: TObject);
var
w :NSWindow;
begin
w := NSView(Self.Handle).window;
w.setTitlebarAppearsTransparent(true);
w.setTitleVisibility( NSWindowTitleHidden);
w.setBackgroundColor( NSColor.greenColor ); // <-- not required, and can changed to any color
...
end;See also
From the Free Pascal wiki, page "Change window title bar colour", as it stood on 2020-02-15 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
