lunes, 18 de octubre de 2010

TransparencyKey and Backcolor inherited automatically to buttons and checkboxes

This is a warning more than a bug of Visual Studio. If you set the the BackColor and TransparencyKey to a WindowsForm both properties will be inherited automatically to buttons and checkboxes that lie inside this form.


1. You have WindowForm1 and this Form contains button1 and checkbox1.
2. You set WindowForm1 BackColor an TransparencyKey to "Lime".
3. button1 and checkbox1 will have BackColor = "Lime" TransparencyKey = "Lime" automatically.

That's it. So why should I consern about it? Well the problem is that when you are working in XP for example with all the visual effects activated the BackColor of all windows controls is overriden by a fancy 3d color ( "fancy" for windows :) ) but if you deactivate all the visual effects, the background of your components will be the BackColor defined.

So? Well if you disable the visual effects and the BackColor of the buttons is transparent you can't click the buttons because like the api of TransparencyKey says, "the actions over the transparency area are sended to the back form".

Simply, if you are using TransparencyKey in a form, don't forget to change the backColor of your buttons and checkboxes to "ControlLight" and always is a good practice to test out ALL your forms with and without effects.

Ps. In fact, you don't need to deactivate all the effects, you just need to deactivate the one that overrides the backcolor of the components, to be honest I'm lazy to research what effect is.

No hay comentarios:

Publicar un comentario