Antoine Posted September 8, 2006 Posted September 8, 2006 Dear all, In VB.NET Pro 2003 I always managed to make the forecolor of a label control nicely fade into the background using lblSomething.Forecolor = Color.FromArgb(a, 255, 255, 255) Where a is counted up or down to get a nice smooth fading effect. BUT now in VB.NET Express 2005 this code doesn't work anymore ??? I tried several options, like transparent backcolor, and the Usecompatibletextrendering but nothing works. The text simply stays opaque. The color is changeable though if I edit the red/green/blue values, but the alpha value doesn't do anything. I can use the opacity function with forms though, so it's not a video driver issue imho. Thanks in advance ! Regards Antoine :) Quote
Leaders snarfblam Posted September 8, 2006 Leaders Posted September 8, 2006 Interesting... at the moment the only solution I can think of is calculating the color resulting from the combination of the backcolor and semi-transparent forecolor yourself, i.e.: 'Calculate solid color resulting from an alpha blend Public Function SolidColorFromAlphaBlend(ForeColor As Color, BackColor As Color) As Color 'Strength of forecolor as a fraction between 0 and 1 Dim Alpha As Single = CType(ForeColor.A / 255, Single) 'Strength of backcolor Dim Omega As Single = 1-Alpha 'Determing the resulting R, G, and B colors based on the 'strength of the component colors, as derived from alpha component Byte NewR = CByte(Math.Min( 'Math.Min ensures no overflow resulting from roundoff error. ForeColor.R * Alpha + BackColor.R * Omega, 255) Byte NewG = CByte(Math.Min( ForeColor.G * Alpha + BackColor.G * Omega, 255) Byte NewB = CByte(Math.Min( ForeColor.B * Alpha + BackColor.B * Omega, 255) Return Color.FromARGB(255, NewR, NewG, NewB) End Function I haven't tested this, and it won't work on top of a background image, but this function would help if the text were on top of a solid background. Quote [sIGPIC]e[/sIGPIC]
Antoine Posted September 11, 2006 Author Posted September 11, 2006 Hello marble eater Something like that I was also thinking of, the text itself is indeed on top of a grey (system color) background. But still I think it is strange. Maybe I didn't install framework correctly ? In .NET 2003 this work fluently :) Quote
Leaders snarfblam Posted September 11, 2006 Leaders Posted September 11, 2006 I have the same problem too. I highly doubt that it is a problem with your installation. It could be a graphics hardware compatability, but I doubt that too. Most likely, intentionally or not, they changed the behavior of the control. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.