@joebigelow / wix / commits / 00bd06f0

Use the DefaultDPI width and height as the source width and height for images.

Sean Hall committed Jul 6, 2020 at 16:10 UTC 00bd06f02cf168eb0752e1d0819969a528742ba7
1 file changed +19 -12
src/dutil/thmutil.cpp
+19 -12
@@ -1258,8 +1258,10 @@ DAPI_(HRESULT) ThemeDrawBackground(
1258 {
1259 HDC hdcMem = ::CreateCompatibleDC(pps->hdc);
1260 HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pTheme->hImage));
1261 + DWORD dwSourceWidth = pTheme->nDefaultDpiWidth;
1262 + DWORD dwSourceHeight = pTheme->nDefaultDpiHeight;
1263
1262 - ::StretchBlt(pps->hdc, 0, 0, pTheme->nWidth, pTheme->nHeight, hdcMem, pTheme->nSourceX, pTheme->nSourceY, pTheme->nWidth, pTheme->nHeight, SRCCOPY);
1264 + ::StretchBlt(pps->hdc, 0, 0, pTheme->nWidth, pTheme->nHeight, hdcMem, pTheme->nSourceX, pTheme->nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY);
1265
1266 ::SelectObject(hdcMem, hDefaultBitmap);
1267 ::DeleteDC(hdcMem);
@@ -3666,6 +3668,8 @@ static HRESULT DrawButton(
3668 {
3669 int nSourceX = pControl->hImage ? 0 : pControl->nSourceX;
3670 int nSourceY = pControl->hImage ? 0 : pControl->nSourceY;
3671 + DWORD dwSourceWidth = pControl->nDefaultDpiWidth;
3672 + DWORD dwSourceHeight = pControl->nDefaultDpiHeight;
3673
3674 HDC hdcMem = ::CreateCompatibleDC(pdis->hDC);
3675 HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage));
@@ -3674,20 +3678,20 @@ static HRESULT DrawButton(
3678 // "clicked" gets priority
3679 if (ODS_SELECTED & pdis->itemState)
3680 {
3677 - nSourceY += pControl->nHeight * 2;
3681 + nSourceY += pControl->nDefaultDpiHeight * 2;
3682 }
3683 // then hover
3684 else if (pControl->dwData & THEME_CONTROL_DATA_HOVER)
3685 {
3682 - nSourceY += pControl->nHeight;
3686 + nSourceY += pControl->nDefaultDpiHeight;
3687 }
3688 // then focused
3689 else if (WS_TABSTOP & dwStyle && ODS_FOCUS & pdis->itemState)
3690 {
3687 - nSourceY += pControl->nHeight * 3;
3691 + nSourceY += pControl->nDefaultDpiHeight * 3;
3692 }
3693
3690 - ::StretchBlt(pdis->hDC, 0, 0, pControl->nWidth, pControl->nHeight, hdcMem, nSourceX, nSourceY, pControl->nWidth, pControl->nHeight, SRCCOPY);
3694 + ::StretchBlt(pdis->hDC, 0, 0, pControl->nWidth, pControl->nHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY);
3695
3696 ::SelectObject(hdcMem, hDefaultBitmap);
3697 ::DeleteDC(hdcMem);
@@ -3773,6 +3777,8 @@ static HRESULT DrawImage(
3777 DWORD dwWidth = pdis->rcItem.right - pdis->rcItem.left;
3778 int nSourceX = pControl->hImage ? 0 : pControl->nSourceX;
3779 int nSourceY = pControl->hImage ? 0 : pControl->nSourceY;
3780 + DWORD dwSourceHeight = pControl->nDefaultDpiHeight;
3781 + DWORD dwSourceWidth = pControl->nDefaultDpiWidth;
3782
3783 BLENDFUNCTION bf = { };
3784 bf.BlendOp = AC_SRC_OVER;
@@ -3784,9 +3790,9 @@ static HRESULT DrawImage(
3790
3791 // Try to draw the image with transparency and if that fails (usually because the image has no
3792 // alpha channel) then draw the image as is.
3787 - if (!::AlphaBlend(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwWidth, dwHeight, bf))
3793 + if (!::AlphaBlend(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, bf))
3794 {
3789 - ::StretchBlt(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwWidth, dwHeight, SRCCOPY);
3795 + ::StretchBlt(pdis->hDC, 0, 0, dwWidth, dwHeight, hdcMem, nSourceX, nSourceY, dwSourceWidth, dwSourceHeight, SRCCOPY);
3796 }
3797
3798 ::SelectObject(hdcMem, hDefaultBitmap);
@@ -3805,29 +3811,30 @@ static HRESULT DrawProgressBar(
3811 DWORD dwProgressPercentage = LOWORD(pControl->dwData);
3812 DWORD dwHeight = pdis->rcItem.bottom - pdis->rcItem.top;
3813 DWORD dwCenter = (pdis->rcItem.right - 2) * dwProgressPercentage / 100;
3814 + DWORD dwSourceHeight = pControl->nDefaultDpiHeight;
3815 int nSourceX = pControl->hImage ? 0 : pControl->nSourceX;
3809 - int nSourceY = (pControl->hImage ? 0 : pControl->nSourceY) + (dwProgressColor * pControl->nHeight);
3816 + int nSourceY = (pControl->hImage ? 0 : pControl->nSourceY) + (dwProgressColor * dwSourceHeight);
3817
3818 HDC hdcMem = ::CreateCompatibleDC(pdis->hDC);
3819 HBITMAP hDefaultBitmap = static_cast<HBITMAP>(::SelectObject(hdcMem, pControl->hImage ? pControl->hImage : pTheme->hImage));
3820
3821 // Draw the left side of the progress bar.
3815 - ::StretchBlt(pdis->hDC, 0, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwHeight, SRCCOPY);
3822 + ::StretchBlt(pdis->hDC, 0, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwSourceHeight, SRCCOPY);
3823
3824 // Draw the filled side of the progress bar, if there is any.
3825 if (0 < dwCenter)
3826 {
3820 - ::StretchBlt(pdis->hDC, 1, 0, dwCenter, dwHeight, hdcMem, nSourceX + 1, nSourceY, 1, dwHeight, SRCCOPY);
3827 + ::StretchBlt(pdis->hDC, 1, 0, dwCenter, dwHeight, hdcMem, nSourceX + 1, nSourceY, 1, dwSourceHeight, SRCCOPY);
3828 }
3829
3830 // Draw the unfilled side of the progress bar, if there is any.
3831 if (dwCenter < static_cast<DWORD>(pdis->rcItem.right - 2))
3832 {
3826 - ::StretchBlt(pdis->hDC, 1 + dwCenter, 0, pdis->rcItem.right - dwCenter - 1, dwHeight, hdcMem, nSourceX + 2, nSourceY, 1, dwHeight, SRCCOPY);
3833 + ::StretchBlt(pdis->hDC, 1 + dwCenter, 0, pdis->rcItem.right - dwCenter - 1, dwHeight, hdcMem, nSourceX + 2, nSourceY, 1, dwSourceHeight, SRCCOPY);
3834 }
3835
3836 // Draw the right side of the progress bar.
3830 - ::StretchBlt(pdis->hDC, pdis->rcItem.right - 1, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwHeight, SRCCOPY);
3837 + ::StretchBlt(pdis->hDC, pdis->rcItem.right - 1, 0, 1, dwHeight, hdcMem, nSourceX, nSourceY, 1, dwSourceHeight, SRCCOPY);
3838
3839 ::SelectObject(hdcMem, hDefaultBitmap);
3840 ::DeleteDC(hdcMem);