Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style ToolTip to make it dark enough in Dark mode #12420

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Darken the TreeView ToolTip in Dark mode
willibrandon committed Nov 12, 2024
commit 1e35f2ba312a69493163929007f6373624094dfe
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
using System.Runtime.InteropServices;
using System.Windows.Forms.Layout;
using System.Windows.Forms.VisualStyles;
using Windows.Win32.Graphics.Dwm;
using Windows.Win32.System.Variant;
using Windows.Win32.UI.Accessibility;
using static System.Windows.Forms.TreeNode;
@@ -1524,6 +1525,26 @@ protected override unsafe void CreateHandle()
}

base.CreateHandle();

#pragma warning disable WFO5001
if (Application.IsDarkModeEnabled)
{
// Get the TreeView's ToolTip handle:
HWND toolTipHandle = (HWND)PInvokeCore.SendMessage(HWND, PInvoke.TVM_GETTOOLTIPS, (WPARAM)0, (LPARAM)0);
PInvoke.SetWindowTheme(toolTipHandle, $"{DarkModeIdentifier}_{ExplorerThemeIdentifier}", null);

// Round the corners of the ToolTip window.
if (OsVersion.IsWindows11_OrGreater())
{
DWM_WINDOW_CORNER_PREFERENCE roundSmall = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUNDSMALL;
PInvoke.DwmSetWindowAttribute(
toolTipHandle,
DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE,
&roundSmall,
sizeof(DWM_WINDOW_CORNER_PREFERENCE));
}
}
#pragma warning restore WFO5001
}

/// <summary>
@@ -1614,7 +1635,7 @@ internal void ForceScrollbarUpdate(bool delayed)
/// <summary>
/// Called by ToolTip to poke in that Tooltip into this ComCtl so that the Native ChildToolTip is not exposed.
/// </summary>
internal override void SetToolTip(ToolTip toolTip)
internal override unsafe void SetToolTip(ToolTip toolTip)
{
if (toolTip is null || !ShowNodeToolTips)
{