[Bug 49487] New: list control custom draw in report view shows blank item if handler clears uItemState CDIS_SELECTED flag

WineHQ Bugzilla wine-bugs at winehq.org
Tue Jun 30 03:13:46 CDT 2020


https://bugs.winehq.org/show_bug.cgi?id=49487

            Bug ID: 49487
           Summary: list control custom draw in report view shows blank
                    item if handler clears uItemState CDIS_SELECTED flag
           Product: Wine
           Version: 5.0.1
          Hardware: x86
                OS: Mac OS X
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: -unknown
          Assignee: wine-bugs at winehq.org
          Reporter: victimofleisure at yahoo.com

I'm the developer of a free software application called Polymeter. The issue
occurs when running Polymeter under Mac OS / High Sierra. I have reproduced it
on multiple machines. I install my software using WineBottler (both 1.8.6 and
4.0.1 exhibited the issue). WineBottler uses WineHQ 5.0 according to their
page.

The issue is per-item background color for *selected* list control items in
report view. The usual method for achieving per-item color is to request item
notifications, and when the prepaint notification is received, set the per-item
background color (pLVCD->clrTextBk). However by default this only works for
non-selected items: selected items continue to use the system default
background color (typically a dark blue) instead of the per-item color. The
workaround is for the custom draw handler to also clear the "selected" flag
(CDIS_SELECTED) in the item state (pLVCD->uItemState). This technique is fairly
common and can be observed in the wild, e.g. here.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/40234af5-a9e7-433f-a372-8f40b20a6d00/clistctrl-customdraw-higlighted-item?forum=vcgeneral

However in my application under WineBottler, this technique causes the list
item in question to be completely white, both text and background.

I enclose a code snippet below. This may be related to 39721 or even a
duplicate of it, but it's hard to tell because that report is not as specific
and doesn't mention selected items. If list control per-item background color
is broken in all cases regardless of selection, that would explain my issue
obviously, but that seems doubtful since many Windows programs use list control
custom draw.

Best wishes,
Chris Korda
https://victimofleisure.github.io/Polymeter/

void CMappingBar::OnListCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
    *pResult = CDRF_DODEFAULT;
    if (theApp.m_bIsMidiLearn) {    // if learning MIDI input
        switch (pLVCD->nmcd.dwDrawStage) {
        case CDDS_PREPAINT:
            *pResult = CDRF_NOTIFYITEMDRAW;
            break;
        case CDDS_ITEMPREPAINT:
            // this will NOT work with LVS_SHOWSELALWAYS; see uItemState in
NMCUSTOMDRAW doc
            if (pLVCD->nmcd.uItemState & CDIS_SELECTED) {    // if item
selected
                pLVCD->clrTextBk = MIDI_LEARN_COLOR;    // customize item
background color
                // trick system into using our custom color instead of
selection color
                pLVCD->nmcd.uItemState &= ~CDIS_SELECTED;    // clear item's
selected flag
            }
            break;
        }
    }
}

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list