Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
175 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...