mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed inactive window caption icon background color
This commit is contained in:
parent
6e15cb7da7
commit
4dbc7d4204
@ -101,7 +101,7 @@ namespace Gdi
|
||||
return;
|
||||
}
|
||||
|
||||
UINT flags = 0;
|
||||
UINT flags = DC_TEXT;
|
||||
if (m_isActive)
|
||||
{
|
||||
flags |= DC_ACTIVE;
|
||||
@ -116,18 +116,27 @@ namespace Gdi
|
||||
OffsetRect(&clipRect, m_windowRect.left - virtualScreenBounds.left, m_windowRect.top - virtualScreenBounds.top);
|
||||
Region clipRgn(clipRect);
|
||||
SelectClipRgn(m_compatDc, clipRgn);
|
||||
CALL_ORIG_FUNC(DrawCaption)(m_hwnd, m_compatDc, &m_tbi.rcTitleBar, flags);
|
||||
SelectClipRgn(m_compatDc, nullptr);
|
||||
|
||||
RECT textRect = m_tbi.rcTitleBar;
|
||||
if (m_hasIcon)
|
||||
{
|
||||
CALL_ORIG_FUNC(DrawCaption)(m_hwnd, m_compatDc, &m_tbi.rcTitleBar, DC_ICON | flags);
|
||||
textRect.left -= 1;
|
||||
RECT r = m_tbi.rcTitleBar;
|
||||
r.right = r.left + r.bottom - r.top;
|
||||
CALL_ORIG_FUNC(FillRect)(m_compatDc, &r,
|
||||
GetSysColorBrush(m_isActive ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
|
||||
|
||||
HICON icon = reinterpret_cast<HICON>(SendMessage(m_hwnd, WM_GETICON, ICON_SMALL, 96));
|
||||
if (!icon)
|
||||
{
|
||||
icon = reinterpret_cast<HICON>(GetClassLong(m_hwnd, GCL_HICONSM));
|
||||
}
|
||||
int width = GetSystemMetrics(SM_CXSMICON);
|
||||
int height = GetSystemMetrics(SM_CYSMICON);
|
||||
int x = r.left + (r.right - r.left - width) / 2 + 2;
|
||||
int y = r.top + (r.bottom - r.top - height) / 2;
|
||||
CALL_ORIG_FUNC(DrawIconEx)(m_compatDc, x, y, icon, width, height, 0, nullptr, DI_NORMAL);
|
||||
}
|
||||
|
||||
textRect.top -= 1;
|
||||
CALL_ORIG_FUNC(DrawCaption)(m_hwnd, m_compatDc, &textRect, DC_TEXT | flags);
|
||||
|
||||
SelectClipRgn(m_compatDc, nullptr);
|
||||
}
|
||||
|
||||
void TitleBar::drawButton(std::size_t tbiIndex, UINT dfcState) const
|
||||
@ -160,11 +169,6 @@ namespace Gdi
|
||||
}
|
||||
}
|
||||
|
||||
void TitleBar::setActive(bool isActive)
|
||||
{
|
||||
m_isActive = isActive;
|
||||
}
|
||||
|
||||
bool TitleBar::isVisible(std::size_t tbiIndex) const
|
||||
{
|
||||
return !(m_tbi.rgstate[tbiIndex] & (STATE_SYSTEM_INVISIBLE | STATE_SYSTEM_OFFSCREEN));
|
||||
|
@ -15,7 +15,6 @@ namespace Gdi
|
||||
void drawButtons() const;
|
||||
void drawCaption() const;
|
||||
void excludeFromClipRegion() const;
|
||||
void setActive(bool isActive);
|
||||
|
||||
private:
|
||||
void adjustButtonSize(RECT& rect) const;
|
||||
|
@ -363,27 +363,13 @@ namespace
|
||||
return CallWindowProc(origWndProc, hwnd, WM_ERASEBKGND, reinterpret_cast<WPARAM>(dc), 0);
|
||||
}
|
||||
|
||||
LRESULT onNcActivate(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT onNcActivate(HWND hwnd, WPARAM /*wParam*/, LPARAM lParam)
|
||||
{
|
||||
if (-1 == lParam)
|
||||
if (-1 != lParam)
|
||||
{
|
||||
return TRUE;
|
||||
RECT r = { -1, -1, 0, 0 };
|
||||
RedrawWindow(hwnd, &r, nullptr, RDW_INVALIDATE | RDW_FRAME);
|
||||
}
|
||||
|
||||
HDC windowDc = GetWindowDC(hwnd);
|
||||
HDC compatDc = Gdi::Dc::getDc(windowDc);
|
||||
|
||||
if (compatDc)
|
||||
{
|
||||
D3dDdi::ScopedCriticalSection lock;
|
||||
Gdi::AccessGuard accessGuard(Gdi::ACCESS_WRITE);
|
||||
Gdi::TitleBar titleBar(hwnd, compatDc);
|
||||
titleBar.setActive(wParam);
|
||||
titleBar.drawAll();
|
||||
Gdi::Dc::releaseDc(windowDc);
|
||||
}
|
||||
|
||||
CALL_ORIG_FUNC(ReleaseDC)(hwnd, windowDc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -461,25 +447,11 @@ namespace
|
||||
LRESULT onSetText(HWND hwnd, WPARAM wParam, LPARAM lParam, WNDPROC origWndProc)
|
||||
{
|
||||
LRESULT result = CallWindowProc(origWndProc, hwnd, WM_SETTEXT, wParam, lParam);
|
||||
if (0 == result ||
|
||||
0 == (CALL_ORIG_FUNC(GetWindowLongA)(hwnd, GWL_STYLE) & WS_CAPTION))
|
||||
if (TRUE == result && (CALL_ORIG_FUNC(GetWindowLongA)(hwnd, GWL_STYLE) & WS_CAPTION))
|
||||
{
|
||||
return result;
|
||||
RECT r = { -1, -1, 0, 0 };
|
||||
RedrawWindow(hwnd, &r, nullptr, RDW_INVALIDATE | RDW_FRAME);
|
||||
}
|
||||
|
||||
HDC windowDc = GetWindowDC(hwnd);
|
||||
HDC compatDc = Gdi::Dc::getDc(windowDc);
|
||||
|
||||
if (compatDc)
|
||||
{
|
||||
D3dDdi::ScopedCriticalSection lock;
|
||||
Gdi::AccessGuard accessGuard(Gdi::ACCESS_WRITE);
|
||||
Gdi::TitleBar titleBar(hwnd, compatDc);
|
||||
titleBar.drawAll();
|
||||
Gdi::Dc::releaseDc(windowDc);
|
||||
}
|
||||
|
||||
CALL_ORIG_FUNC(ReleaseDC)(hwnd, windowDc);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user