-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable dark mode support for shell context menu #298
(Thanks to chip33 for API hint)
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// <copyright file="Themes.cs" company="PlaceholderCompany"> | ||
// Copyright (c) PlaceholderCompany. All rights reserved. | ||
// </copyright> | ||
// | ||
// Copyright (c) 2023 Peter Kirmeier | ||
|
||
namespace SystemTrayMenu.DllImports | ||
{ | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
|
||
/// <summary> | ||
/// See: https://gist.github.com/rounk-ctrl/b04e5622e30e0d62956870d5c22b7017 | ||
/// See: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/e36eb4c0-4370-4933-943d-b6fe22677e6c/dark-mode-apis?forum=windowssdk | ||
/// Wraps the method calls to native Windows DLLs. | ||
/// </summary> | ||
public static partial class NativeMethods | ||
{ | ||
internal enum PreferredAppMode : int | ||
{ | ||
Default = 0, | ||
AllowDark = 1, | ||
ForceDark = 2, | ||
ForceLight = 3, | ||
} | ||
|
||
/// <summary> | ||
/// No official documentation. | ||
/// Seems to set mode that the UI shall use for rendering UI elements. | ||
/// </summary> | ||
/// <param name="preferredAppMode">Desired mode.</param> | ||
/// <returns>Undocumented.</returns> | ||
[SupportedOSPlatform("windows")] | ||
[DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)] | ||
internal static extern int SetPreferredAppMode(PreferredAppMode preferredAppMode); | ||
|
||
/// <summary> | ||
/// No official documentation. | ||
/// Seems to switch UI mode which was set by SetPreferredAppMode. | ||
/// </summary> | ||
[SupportedOSPlatform("windows")] | ||
[DllImport("uxtheme.dll", EntryPoint = "#136", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)] | ||
internal static extern void FlushMenuThemes(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters