@@ -2505,28 +2505,35 @@ LRESULT CSearchDlg::ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD)
2505
2505
LPWSTR pMatch = lv.pszText + colMatch - 1 ;
2506
2506
SIZE textSize = {0 , 0 };
2507
2507
2508
- rc.left += CDPIAware::Instance ().Scale (*this , 6 );
2508
+ rc.left += CDPIAware::Instance ().Scale (*this , 6 );
2509
+ rc.right -= CDPIAware::Instance ().Scale (*this , 6 );
2509
2510
2510
2511
// Not precise sometimes.
2511
2512
// We keep the text and draw a transparent rectangle only. So, will not break the text.
2512
2513
GetTextExtentPoint32 (hdc, lv.pszText , colMatch - 1 , &textSize);
2513
2514
rc.left += textSize.cx ;
2515
+ if (rc.left >= rc.right )
2516
+ {
2517
+ break ;
2518
+ }
2514
2519
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
+ }
2516
2524
2525
+ LONG width = rc.right - rc.left ;
2517
2526
LONG height = rc.bottom - rc.top ;
2518
2527
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 }} };
2520
2529
BLENDFUNCTION blend = {AC_SRC_OVER, 0 , 92 , 0 }; // 36%
2521
2530
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};
2523
2532
SelectObject (hcdc, hBitmap);
2524
2533
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);
2526
2535
DeleteObject (hBitmap);
2527
2536
DeleteDC (hcdc);
2528
-
2529
- return CDRF_DODEFAULT;
2530
2537
}
2531
2538
}
2532
2539
}
0 commit comments