Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Application.EnableVisualStyles() do anything?

I'm very picky when it comes to understanding a new language, and recently I've taken up learning C#. So I like to know everything that is going on when I create a new Application - in this case a new Windows Forms Application. I created one and was given some generated code from Visual Studio and one line was Application.EnableVisualStyles().

I did some research on MSDN and found this article: Application.EnableVisualStyles(). I performed the example that they presented expecting the button not to be visible when I commented out the said line. Nothing happened! It appeared that nothing changed. I know this is a very basic example but shouldn't something have changed? If this is so critical in the Main() procedure what exactly is it doing that I'm missing?

like image 715
Adam Beck Avatar asked Jul 20 '11 15:07

Adam Beck


People also ask

What is application EnableVisualStyles?

EnableVisualStyles() and run the application you can see all your controls rendered with current operating system theme settings. Means, If your operating system is Windows it will use the built-in Windows theaming to style controls and classic Windows look and feel if EnableVisualStyle() is commented.

Where is system Windows Forms DLL?

System. Windows. Forms. dll is located in the folder C:\WINDOWS\Microsoft.NET\Framework\v2.


1 Answers

Yes it does, but you need have certain settings turned on in your OS otherwise you won't be able to see what it is.

Here are some screenshots of that same application on my system:

Application.EnableVisualStyles(); 

With visual themes

// Application.EnableVisualStyles(); 

Without visual themes

If buttons in other applications look like the second screenshot then you will always see buttons un-themed regardless of whether you use Application.EnableVisualStyles(), because they are turned off by the OS - the way to turn them back on depends on your OS but usually involves going to the Performance >> Visual Effects dialog.

like image 155
Justin Avatar answered Sep 17 '22 22:09

Justin