From 00bd06f02cf168eb0752e1d0819969a528742ba7 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 6 Jul 2020 16:10:13 +1000 Subject: Use the DefaultDPI width and height as the source width and height for images. --- src/dutil/thmutil.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/dutil/thmutil.cpp b/src/dutil/thmutil.cpp index b40868a1..4da489e4 100644 --- a/src/dutil/thmutil.cpp +++ b/src/dutil/thmutil.cpp @@ -1258,8 +1258,10 @@ DAPI_(HRESULT) ThemeDrawBackground( { HDC hdcMem = ::CreateCompatibleDC(pps->hdc); HBITMAP hDefaultBitmap = static_cast(::SelectObject(hdcMem, pTheme->hImage)); + DWORD dwSourceWidth = pTheme->nDefaultDpiWidth; + DWORD dwSourceHeight = pTheme->nDefaultDpiHeight; - ::StretchBlt(pps->hdc, 0, 0, pTheme->nWidth, pTheme->nHeight, hdcMem, pTheme->nSourceX, pTheme->nSourceY, pTheme->nWidth, pTheme->nHeight, SRCCOPY); + ::StretchBlt(pps->hdc, 0, 0, pTheme->nWidth, pTheme->nHeight, hdcMem, pTheme->nSourceX, pTheme->nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY); ::SelectObject(hdcMem, hDefaultBitmap); ::DeleteDC(hdcMem); @@ -3666,6 +3668,8 @@ static HRESULT DrawButton( { int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; int nSourceY = pControl->hImage ? 0 : pControl->nSourceY; + DWORD dwSourceWidth = pControl->nDefaultDpiWidth; + DWORD dwSourceHeight = pControl->nDefaultDpiHeight; HDC hdcMem = ::CreateCompatibleDC(pdis->hDC); HBITMAP hDefaultBitmap = static_cast(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage)); @@ -3674,20 +3678,20 @@ static HRESULT DrawButton( // "clicked" gets priority if (ODS_SELECTED & pdis->itemState) { - nSourceY += pControl->nHeight * 2; + nSourceY += pControl->nDefaultDpiHeight * 2; } // then hover else if (pControl->dwData & THEME_CONTROL_DATA_HOVER) { - nSourceY += pControl->nHeight; + nSourceY += pControl->nDefaultDpiHeight; } // then focused else if (WS_TABSTOP & dwStyle && ODS_FOCUS & pdis->itemState) { - nSourceY += pControl->nHeight * 3; + nSourceY += pControl->nDefaultDpiHeight * 3; } - ::StretchBlt(pdis->hDC, 0, 0, pControl->nWidth, pControl->nHeight, hdcMem, nSourceX, nSourceY, pControl->nWidth, pControl->nHeight, SRCCOPY); + ::StretchBlt(pdis->hDC, 0, 0, pControl->nWidth, pControl->nHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY); ::SelectObject(hdcMem, hDefaultBitmap); ::DeleteDC(hdcMem); @@ -3773,6 +3777,8 @@ static HRESULT DrawImage( DWORD dwWidth = pdis->rcItem.right - pdis->rcItem.left; int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; int nSourceY = pControl->hImage ? 0 : pControl->nSourceY; + DWORD dwSourceHeight = pControl->nDefaultDpiHeight; + DWORD dwSourceWidth = pControl->nDefaultDpiWidth; BLENDFUNCTION bf = { }; bf.BlendOp = AC_SRC_OVER; @@ -3784,9 +3790,9 @@ static HRESULT DrawImage( // Try to draw the image with transparency and if that fails (usually because the image has no // alpha channel) then draw the image as is. - if (!::AlphaBlend(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwWidth, dwHeight, bf)) + if (!::AlphaBlend(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, bf)) { - ::StretchBlt(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwWidth, dwHeight, SRCCOPY); + ::StretchBlt(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY); } ::SelectObject(hdcMem, hDefaultBitmap); @@ -3805,29 +3811,30 @@ static HRESULT DrawProgressBar( DWORD dwProgressPercentage = LOWORD(pControl->dwData); DWORD dwHeight = pdis->rcItem.bottom - pdis->rcItem.top; DWORD dwCenter = (pdis->rcItem.right - 2) * dwProgressPercentage / 100; + DWORD dwSourceHeight = pControl->nDefaultDpiHeight; int nSourceX = pControl->hImage ? 0 : pControl->nSourceX; - int nSourceY = (pControl->hImage ? 0 : pControl->nSourceY) + (dwProgressColor * pControl->nHeight); + int nSourceY = (pControl->hImage ? 0 : pControl->nSourceY) + (dwProgressColor * dwSourceHeight); HDC hdcMem = ::CreateCompatibleDC(pdis->hDC); HBITMAP hDefaultBitmap = static_cast(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage)); // Draw the left side of the progress bar. - ::StretchBlt(pdis->hDC, 0, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwHeight, SRCCOPY); + ::StretchBlt(pdis->hDC, 0, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwSourceHeight, SRCCOPY); // Draw the filled side of the progress bar, if there is any. if (0 < dwCenter) { - ::StretchBlt(pdis->hDC, 1, 0, dwCenter, dwHeight, hdcMem, nSourceX + 1, nSourceY, 1, dwHeight, SRCCOPY); + ::StretchBlt(pdis->hDC, 1, 0, dwCenter, dwHeight, hdcMem, nSourceX + 1, nSourceY, 1, dwSourceHeight, SRCCOPY); } // Draw the unfilled side of the progress bar, if there is any. if (dwCenter < static_cast(pdis->rcItem.right - 2)) { - ::StretchBlt(pdis->hDC, 1 + dwCenter, 0, pdis->rcItem.right - dwCenter - 1, dwHeight, hdcMem, nSourceX + 2, nSourceY, 1, dwHeight, SRCCOPY); + ::StretchBlt(pdis->hDC, 1 + dwCenter, 0, pdis->rcItem.right - dwCenter - 1, dwHeight, hdcMem, nSourceX + 2, nSourceY, 1, dwSourceHeight, SRCCOPY); } // Draw the right side of the progress bar. - ::StretchBlt(pdis->hDC, pdis->rcItem.right - 1, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwHeight, SRCCOPY); + ::StretchBlt(pdis->hDC, pdis->rcItem.right - 1, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwSourceHeight, SRCCOPY); ::SelectObject(hdcMem, hDefaultBitmap); ::DeleteDC(hdcMem); -- cgit v1.2.3-55-g6feb