Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,13 @@ private unsafe void CreateHandle()
{
PInvoke.SetWindowTheme(HWND, string.Empty, string.Empty);
}

#pragma warning disable WFO5001
if (Application.IsDarkModeEnabled)
Comment thread
willibrandon marked this conversation as resolved.
Outdated
{
PInvoke.SetWindowTheme(HWND, string.Empty, string.Empty);
}
#pragma warning restore WFO5001
}

// If in OwnerDraw mode, we don't want the default border.
Expand Down Expand Up @@ -770,15 +777,11 @@ private unsafe void CreateHandle()
// Set active status.
PInvokeCore.SendMessage(this, PInvoke.TTM_ACTIVATE, (WPARAM)(BOOL)_active);

if (BackColor != SystemColors.Info)
{
PInvokeCore.SendMessage(this, PInvoke.TTM_SETTIPBKCOLOR, (WPARAM)BackColor);
}
// Set background color.
PInvokeCore.SendMessage(this, PInvoke.TTM_SETTIPBKCOLOR, (WPARAM)_backColor);

if (ForeColor != SystemColors.InfoText)
{
PInvokeCore.SendMessage(this, PInvoke.TTM_SETTIPTEXTCOLOR, (WPARAM)ForeColor);
}
// Set text color.
PInvokeCore.SendMessage(this, PInvoke.TTM_SETTIPTEXTCOLOR, (WPARAM)_foreColor);

if (_toolTipIcon > 0 || !string.IsNullOrEmpty(_toolTipTitle))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,36 @@ public void ToolTip_ToString_Invoke_ReturnsExpected()
Assert.Equal("System.Windows.Forms.ToolTip InitialDelay: 500, ShowAlways: False", toolTip.ToString());
}

#pragma warning disable WFO5001
[WinFormsFact]
public void ToolTip_DarkMode_GetColors_ReturnsExpected()
{
if (SystemInformation.HighContrast)
{
// We don't run this test in HighContrast mode.
return;
}

SystemColorMode colorMode = Application.ColorMode;
Application.SetColorMode(SystemColorMode.Dark);

using SubToolTip toolTip = new();

Assert.NotEqual(IntPtr.Zero, toolTip.Handle); // A workaround to create the toolTip native window Handle
Comment thread
willibrandon marked this conversation as resolved.
Outdated

var backgroundColor = PInvokeCore.SendMessage(toolTip, PInvoke.TTM_GETTIPBKCOLOR);
Color backColor = ColorTranslator.FromWin32((int)backgroundColor);

var textColor = PInvokeCore.SendMessage(toolTip, PInvoke.TTM_GETTIPTEXTCOLOR);
Color foreColor = ColorTranslator.FromWin32((int)textColor);

Assert.Equal(SystemColors.Info.ToArgb(), backColor.ToArgb());
Assert.Equal(SystemColors.InfoText.ToArgb(), foreColor.ToArgb());

Application.SetColorMode(colorMode);
Comment thread
willibrandon marked this conversation as resolved.
Outdated
}
#pragma warning restore WFO5001

[WinFormsFact]
public void ToolTip_SetToolTipToControl_Invokes_SetToolTip_OfControl()
{
Expand Down