From 4986414dda2a372156c6414a0f4c5b72aa24dcfd Mon Sep 17 00:00:00 2001 From: Jimmy Quach Date: Tue, 29 Oct 2024 17:18:18 -0700 Subject: [PATCH] fix(windows): System dark theme not applying to title bar --- Classes/WindowsInterface.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Classes/WindowsInterface.cs b/Classes/WindowsInterface.cs index c8b928ae..6d3c8660 100644 --- a/Classes/WindowsInterface.cs +++ b/Classes/WindowsInterface.cs @@ -10,6 +10,7 @@ using System.IO; using System.Net; using System.Net.Sockets; +using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Windows.Forms; @@ -22,6 +23,15 @@ public partial class WindowsInterface : Form { public static WindowsInterface Instance; private static Socket listener; + [DllImport("DwmApi")] + private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize); + + // https://stackoverflow.com/a/64927217 + protected override void OnHandleCreated(EventArgs e) { + if (DwmSetWindowAttribute(Handle, 19, new[] { 1 }, 4) != 0) + DwmSetWindowAttribute(Handle, 20, new[] { 1 }, 4); + } + public WindowsInterface() { Instance = this; InitializeComponent();