Menu

#2179 Win32: ListBoxX::GetDesiredRect should use correct technology to measure width

Bug
closed-fixed
nobody
5
2026-04-07
2020-05-31
mberchtold
No

In ListBoxX::GetDesiredRect, GDI (GetTextExtentPoint32) is always used to measure the text width. This should depend on the technology class member. If it is not SCWIN_TECH_GDI, then D2D should be used. This would be consistent with the code in ListBoxX::Draw. Right now the text is measure width GDI but drawn with D2D. The text width might be incorrect as D2D and GDI (may) use different text render implementations.
The text measurement implementation for D2D can be taken from SurfaceD2D::WidthText.

Discussion

  • Zufu Liu

    Zufu Liu - 2020-05-31

    test is drawn with GDI, not D2D.

    if (unicodeMode) {
        const TextWide tbuf(text, unicodeMode);
        ::DrawTextW(pDrawItem->hDC, tbuf.buffer, tbuf.tlen, &rcText, DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOCLIP);
    } else {
        ::DrawTextA(pDrawItem->hDC, text, len, &rcText, DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOCLIP);
    }
    
     
    • mberchtold

      mberchtold - 2020-05-31

      Correct. But the image is drawn with D2D. I think everything should be measured/drawn with D2D if the technlogy is set to D2D.

       
  • Neil Hodgson

    Neil Hodgson - 2020-05-31

    Using DirectWrite for drawing and measuring the text in lists would be reasonable.

     
  • Zufu Liu

    Zufu Liu - 2026-04-07
    • labels: --> Scintilla, win32, directwrite
    • status: open --> closed-fixed
     
  • Zufu Liu

    Zufu Liu - 2026-04-07

    Fixed in v5.5.6.

     

Log in to post a comment.

MongoDB Logo MongoDB