-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BackColor and ForeColor in DrawListViewColumnHeaderEventArgs have alpha component set to 0 #13048
Comments
Thanks @Zheng-Li01 for starting to look into this issue. In the release/7.0 branch
|
Using dotPeek to decompile the .NET Framework 4.8 implementation gives this source code:
|
We accidentally dropped the call to ColorTranslator, which properly handles alpha when converting COLORREF. COLORREF's implicit conversion does this correctly. Fixes dotnet#13048
@anders9ustafsson Thanks for the report! I've got a fix up for .NET 10. Hopefully you can work around this by changing the color in the event args to remove the transparency. |
We accidentally dropped the call to ColorTranslator, which properly handles alpha when converting COLORREF. COLORREF's implicit conversion does this correctly. Fixes #13048
Many thanks, @JeremyKuhne ! Any chance that the fix will make it into the next .NET 8 update as well? |
@anders9ustafsson I would have to try and get approval from servicing. If I get approval, it might not make the next update (might be the one after). Are you able to work around this? |
Yes, I have already implemented a workaround, so we can cope without a correction in .NET 8. I just want to get rid of the workaround as soon as possible 🙂 |
We accidentally dropped the call to ColorTranslator, which properly handles alpha when converting COLORREF. COLORREF's implicit conversion does this correctly. Fixes dotnet#13048
.NET version
.NET 8.0
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
In our code, we are using the
OwnerDraw
mode forSystem.Windows.Forms.ListView
. When accessing theForeColor
andBackColor
properties ofDrawListViewColumnHeaderEventArgs
, we notice that the alpha component of respective color is 0, although we would have expected 255. Therefore, e.g. when drawing text usingForeColor
, no text can be seen in the header.Looking at the source code where
DrawListViewColumnHeaderEventArgs
is defined inListView
, I notice that the colors are obtained using P/Invoke methodsGetTextColor
andGetBkColor
, respectively:However, if I interpret the documentation for the GetTextColor function correctly, it returns a
COLORREF
value, which only appears to be an RGB color representation with remaining byte set to 0 (0x00bbggrr). Is this the explanation why the alpha component is 0 in theForeColor
andBackColor
properties?Steps to reproduce
Compare with:
The text was updated successfully, but these errors were encountered: