@@ -2505,28 +2505,35 @@ LRESULT CSearchDlg::ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD)
25052505 LPWSTR pMatch = lv.pszText + colMatch - 1 ;
25062506 SIZE textSize = {0 , 0 };
25072507
2508- rc.left += CDPIAware::Instance ().Scale (*this , 6 );
2508+ rc.left += CDPIAware::Instance ().Scale (*this , 6 );
2509+ rc.right -= CDPIAware::Instance ().Scale (*this , 6 );
25092510
25102511 // Not precise sometimes.
25112512 // We keep the text and draw a transparent rectangle only. So, will not break the text.
25122513 GetTextExtentPoint32 (hdc, lv.pszText , colMatch - 1 , &textSize);
25132514 rc.left += textSize.cx ;
2515+ if (rc.left >= rc.right )
2516+ {
2517+ break ;
2518+ }
25142519 GetTextExtentPoint32 (hdc, pMatch, pInfo->matchLengths [subIndex], &textSize);
2515- rc.right = rc.left + textSize.cx ;
2520+ if (rc.right > rc.left + textSize.cx )
2521+ {
2522+ rc.right = rc.left + textSize.cx ;
2523+ }
25162524
2525+ LONG width = rc.right - rc.left ;
25172526 LONG height = rc.bottom - rc.top ;
25182527 HDC hcdc = CreateCompatibleDC (hdc);
2519- BITMAPINFO bmi = { {sizeof (BITMAPINFOHEADER), textSize. cx , height, 1 , 32 , BI_RGB, textSize. cx * height * 4u , 0 , 0 , 0 , 0 }, {{0 , 0 , 0 , 0 }} };
2528+ BITMAPINFO bmi = { {sizeof (BITMAPINFOHEADER), width , height, 1 , 32 , BI_RGB, width * height * 4u , 0 , 0 , 0 , 0 }, {{0 , 0 , 0 , 0 }} };
25202529 BLENDFUNCTION blend = {AC_SRC_OVER, 0 , 92 , 0 }; // 36%
25212530 HBITMAP hBitmap = CreateDIBSection (hcdc, &bmi, DIB_RGB_COLORS, NULL , NULL , 0x0 );
2522- RECT rc2 = {0 , 0 , textSize. cx , height};
2531+ RECT rc2 = {0 , 0 , width , height};
25232532 SelectObject (hcdc, hBitmap);
25242533 FillRect (hcdc, &rc2, CreateSolidBrush (RGB (255 , 255 , 0 )));
2525- AlphaBlend (hdc, rc.left , rc.top , textSize. cx , height, hcdc, 0 , 0 , textSize. cx , height, blend);
2534+ AlphaBlend (hdc, rc.left , rc.top , width , height, hcdc, 0 , 0 , width , height, blend);
25262535 DeleteObject (hBitmap);
25272536 DeleteDC (hcdc);
2528-
2529- return CDRF_DODEFAULT;
25302537 }
25312538 }
25322539 }
0 commit comments