added interface themes
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user