Depending on the theme, if there was a header, the border ends up painted lower than it should be, and clipped by the header.
7-Zip file manager, the reason why the offset was added in 5f0dcf79185941c4faff35d1cc9c758160f3a27d in the first place, still renders correctly.
Before:
![before](/uploads/8321f45c657469278b2787edfa147b20/before.png)
After:
![after](/uploads/013241f4cd3b893c7f4073b6a9fe8119/after.png)
EDIT1: Actually compared screenshots of 7-Zip file manager and looks like the headers are now painted consistently after highlighting them.
![7zFM-before-hilite](/uploads/64fe3fb80002c847c2e9270337bab4e8/7zFM-before-hilite.png)
![7zFM-after-hilite](/uploads/4db4778c2ad6d27eddbd4a1202b41881/7zFM-after-hilite.png)
-- v2: comctl32/listview: Exclude header area in WM_NCPAINT.
From: Vladislav Timonin timoninvlad@yandex.ru
An improvement of 5f0dcf79185941c4faff35d1cc9c758160f3a27d, which, depending on theme, had an issue with drawing the top border clipped inside the header. --- dlls/comctl32/listview.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 7c394d60273..1e9522de012 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -10712,15 +10712,21 @@ static LRESULT LISTVIEW_NCPaint(const LISTVIEW_INFO *infoPtr, HRGN region) if (region != (HRGN)1) CombineRgn (cliprgn, cliprgn, region, RGN_AND);
- OffsetRect(&r, -r.left, -r.top); + dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW | DCX_INTERSECTRGN); if (infoPtr->hwndHeader && LISTVIEW_IsHeaderEnabled(infoPtr)) { + LONG border_cx, border_cy; + GetWindowRect(infoPtr->hwndHeader, &window_rect); - r.top = min(r.bottom, r.top + window_rect.bottom - window_rect.top); - } + border_cx = window_rect.left - r.left; + border_cy = window_rect.top - r.top;
- dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW|DCX_INTERSECTRGN); + OffsetRect(&window_rect, -window_rect.left, -window_rect.top); + OffsetRect(&window_rect, border_cx, border_cy); + ExcludeClipRect(dc, window_rect.left, window_rect.top, window_rect.right, window_rect.bottom); + }
+ OffsetRect(&r, -r.left, -r.top); if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0)) DrawThemeParentBackground(infoPtr->hwndSelf, dc, &r); DrawThemeBackground (theme, dc, 0, 0, &r, 0);
Was pointed out that the `DTBG_OMITCONTENT`/`DTBG_OMITBORDER` approach wasn't handling `BT_IMAGEFILE` quite right. So clipping it is.
Zhiyi Zhang (@zhiyi) commented about dlls/comctl32/listview.c:
- OffsetRect(&r, -r.left, -r.top);
- dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW | DCX_INTERSECTRGN); if (infoPtr->hwndHeader && LISTVIEW_IsHeaderEnabled(infoPtr)) {
LONG border_cx, border_cy;
GetWindowRect(infoPtr->hwndHeader, &window_rect);
r.top = min(r.bottom, r.top + window_rect.bottom - window_rect.top);
- }
border_cx = window_rect.left - r.left;
border_cy = window_rect.top - r.top;
- dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW|DCX_INTERSECTRGN);
OffsetRect(&window_rect, -window_rect.left, -window_rect.top);
OffsetRect(&window_rect, border_cx, border_cy);
These two lines can be replaced with OffsetRect(&window_rect, -r.left, -r.top); and you can remove border_cx/cy.
Otherwise, the patch looks good to me.