Fix RS5 dark scrollbar theme, Fix button BS_ICON style drawing
@@ -339,7 +339,7 @@ BOOLEAN CALLBACK PhpThemeWindowEnumChildWindows(
}
else if (PhEqualStringZ(windowClassName, L"ScrollBar", FALSE))
{
- if (WindowsVersion > WINDOWS_10_RS4)
+ if (WindowsVersion >= WINDOWS_10_RS5)
{
switch (PhpThemeColorMode)
{
@@ -486,7 +486,7 @@ BOOLEAN CALLBACK PhpReInitializeThemeWindowEnumChildWindows(
}
else if (PhEqualStringZ(windowClassName, L"ScrollBar", FALSE))
{
- if (WindowsVersion > WINDOWS_10_RS4)
+ if (WindowsVersion >= WINDOWS_10_RS5)
{
switch (PhpThemeColorMode)
{
@@ -856,9 +856,11 @@ LRESULT CALLBACK PhpThemeWindowDrawButton(
case CDDS_PREPAINT:
{
PPH_STRING buttonText;
+ ULONG_PTR buttonStyle;
HFONT oldFont;
buttonText = PhGetWindowText(DrawInfo->hdr.hwndFrom);
+ buttonStyle = PhGetWindowStyle(DrawInfo->hdr.hwndFrom);
if (isSelected)
{
@@ -906,7 +908,72 @@ LRESULT CALLBACK PhpThemeWindowDrawButton(
FillRect(DrawInfo->hdc, &DrawInfo->rc, GetStockObject(DC_BRUSH));
}
- if ((PhGetWindowStyle(DrawInfo->hdr.hwndFrom) & BS_CHECKBOX) == BS_CHECKBOX)
+ if ((buttonStyle & BS_ICON) == BS_ICON)
+ {
+ RECT bufferRect =
+ {
+ 0, 0,
+ DrawInfo->rc.right - DrawInfo->rc.left,
+ DrawInfo->rc.bottom - DrawInfo->rc.top
+ };
+ HICON buttonIcon;
+
+ SetDCBrushColor(DrawInfo->hdc, RGB(65, 65, 65));
+ FrameRect(DrawInfo->hdc, &DrawInfo->rc, GetStockObject(DC_BRUSH));
+
+ if (!(buttonIcon = Static_GetIcon(DrawInfo->hdr.hwndFrom, 0)))
+ buttonIcon = (HICON)SendMessage(DrawInfo->hdr.hwndFrom, BM_GETIMAGE, IMAGE_ICON, 0);
+
+ if (buttonIcon)
+ {
+ ICONINFO iconInfo;
+ BITMAP bmp;
+ LONG width;
+ LONG height;
+
+ memset(&iconInfo, 0, sizeof(ICONINFO));
+ memset(&bmp, 0, sizeof(BITMAP));
+
+ GetIconInfo(buttonIcon, &iconInfo);
+
+ if (iconInfo.hbmColor)
+ {
+ if (GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bmp))
+ {
+ width = bmp.bmWidth;
+ height = bmp.bmHeight;
+ }
+
+ DeleteObject(iconInfo.hbmColor);
+ }
+ else if (iconInfo.hbmMask)
+ {
+ if (GetObject(iconInfo.hbmMask, sizeof(BITMAP), &bmp))
+ {
+ width = bmp.bmWidth;
+ height = bmp.bmHeight / 2;
+ }
+
+ DeleteObject(iconInfo.hbmMask);
+ }
+
+ bufferRect.left += 1; // HACK
+ bufferRect.top += 1; // HACK
+
+ DrawIconEx(
+ DrawInfo->hdc,
+ bufferRect.left + ((bufferRect.right - bufferRect.left) - width) / 2,
+ bufferRect.top + ((bufferRect.bottom - bufferRect.top) - height) / 2,
+ buttonIcon,
+ width,
+ height,
+ 0,
+ NULL,
+ DI_NORMAL
+ );
+ }
+ }
+ else if ((buttonStyle & BS_CHECKBOX) == BS_CHECKBOX)
{
HFONT newFont = PhDuplicateFontWithNewHeight(PhApplicationFont, 22);
oldFont = SelectFont(DrawInfo->hdc, newFont);
