Sign in Join
Wiki copytemporary

Change window title bar colour: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Change window title bar colour

OldNewLine
1+*(macOS only)*
2+
3+For macOS 10.10 and later, the following code may be used to change the colour of a window's title bar.
4+
5+``` pascal
6+ {$modeswitch objectivec2}
7+
8+ interface
9+
10+ uses
11+ CocoaAll,
12+ ...;
13+
14+ const
15+ NSWindowTitleVisible = 0;
16+ NSWindowTitleHidden = 1;
17+
18+ type
19+ NSWindowTitleVisibility = NSInteger;
20+
21+ NSWindowGlam = objccategory external (NSWindow)
22+ function titleVisibility: NSWindowTitleVisibility; message 'titleVisibility';
23+ procedure setTitleVisibility(AVisibility: NSWindowTitleVisibility); message 'setTitleVisibility:';
24+ function titlebarAppearsTransparent: Boolean; message 'titlebarAppearsTransparent';
25+ procedure setTitlebarAppearsTransparent(AFlag: Boolean); message 'setTitlebarAppearsTransparent:';
26+ end;
27+
28+ { TForm1 }
29+
30+ procedure TForm1.FormShow(Sender: TObject);
31+ var
32+ w :NSWindow;
33+ begin
34+ w := NSView(Self.Handle).window;
35+ w.setTitlebarAppearsTransparent(true);
36+ w.setTitleVisibility( NSWindowTitleHidden);
37+
38+ w.setBackgroundColor( NSColor.greenColor ); // <-- not required, and can changed to any color
39+
40+ ...
41+
42+ end;
43+```
44+
45+# See also
46+
47+- [[Portal:Mac|macOS Portal]]
48+- [[Cocoa Interface]]
49+
50+---
51+*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](/wiki-contact).*
52+Category: Code Snippets
53+Category: macOS

Back to history