added interface themes

This commit is contained in:
2026-08-09 00:09:47 +05:00
parent 8a19cb6a9c
commit b581d560b0
16 changed files with 607 additions and 19 deletions
+30
View File
@@ -0,0 +1,30 @@
using System.Runtime.InteropServices;
namespace CursorLang.Interop;
/// <summary>
/// Оформление рамки окна средствами системы: заголовок рисует Windows,
/// и в тёмной теме его нужно переключать отдельно от содержимого окна.
/// </summary>
internal static class WindowThemeNative
{
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hWnd, int attribute, ref int value, int size);
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
/// <summary>
/// Перекрашивает заголовок окна. На сборках Windows 10 до 2004 атрибут
/// не поддерживается — заголовок просто останется светлым.
/// </summary>
internal static void SetDarkTitleBar(IntPtr hWnd, bool isDark)
{
if (hWnd == IntPtr.Zero)
{
return;
}
int value = isDark ? 1 : 0;
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, ref value, sizeof(int));
}
}