Difference between revisions of "Change window title bar colour"
From Free Pascal wiki
Jump to navigationJump to search (New content) |
m (Tweaked code example) |
||
Line 10: | Line 10: | ||
uses | uses | ||
CocoaAll, | CocoaAll, | ||
− | + | ...; | |
+ | |||
const | const | ||
NSWindowTitleVisible = 0; | NSWindowTitleVisible = 0; | ||
Line 36: | Line 37: | ||
w.setBackgroundColor( NSColor.greenColor ); // <-- not required, and can changed to any color | w.setBackgroundColor( NSColor.greenColor ); // <-- not required, and can changed to any color | ||
+ | |||
+ | ... | ||
+ | |||
+ | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 00:39, 16 February 2020
This article applies to macOS only.
See also: Multiplatform Programming Guide
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;