Remove menubar white line under dark mode

Fix #9984, close #9985
This commit is contained in:
Adam D. Walling 2021-06-09 20:13:10 -04:00 committed by Don Ho
parent aa17a4bc7a
commit 7e139e1ba2
3 changed files with 45 additions and 1 deletions

View File

@ -161,7 +161,22 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
{
// Note: lParam is -1 to prevent endless loops of calls
::SendMessage(_dockingManager.getHSelf(), WM_NCACTIVATE, wParam, -1);
return ::DefWindowProc(hwnd, message, wParam, lParam);
result = ::DefWindowProc(hwnd, message, wParam, lParam);
if (NppDarkMode::isDarkMenuEnabled() && NppDarkMode::isEnabled())
{
NppDarkMode::drawUAHMenuNCBottomLine(hwnd);
}
return result;
}
case WM_NCPAINT:
{
result = ::DefWindowProc(hwnd, message, wParam, lParam);
if (NppDarkMode::isDarkMenuEnabled() && NppDarkMode::isEnabled())
{
NppDarkMode::drawUAHMenuNCBottomLine(hwnd);
}
return result;
}
case WM_ERASEBKGND:

View File

@ -353,6 +353,34 @@ namespace NppDarkMode
}
}
void drawUAHMenuNCBottomLine(HWND hWnd)
{
MENUBARINFO mbi = { sizeof(mbi) };
if (!GetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi))
{
return;
}
RECT rcClient = { 0 };
GetClientRect(hWnd, &rcClient);
MapWindowPoints(hWnd, nullptr, (POINT*)&rcClient, 2);
RECT rcWindow = { 0 };
GetWindowRect(hWnd, &rcWindow);
OffsetRect(&rcClient, -rcWindow.left, -rcWindow.top);
// the rcBar is offset by the window rect
RECT rcAnnoyingLine = rcClient;
rcAnnoyingLine.bottom = rcAnnoyingLine.top;
rcAnnoyingLine.top--;
HDC hdc = GetWindowDC(hWnd);
FillRect(hdc, &rcAnnoyingLine, NppDarkMode::getDarkerBackgroundBrush());
ReleaseDC(hWnd, hdc);
}
// from DarkMode.h
void initExperimentalDarkMode(bool fixDarkScrollbar, bool dark)

View File

@ -55,6 +55,7 @@ namespace NppDarkMode
// processes messages related to UAH / custom menubar drawing.
// return true if handled, false to continue with normal processing in your wndproc
bool runUAHWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr);
void drawUAHMenuNCBottomLine(HWND hWnd);
// from DarkMode.h
void initExperimentalDarkMode(bool fixDarkScrollbar, bool dark);