Button following windows style

Antoine

Regular
Joined
Aug 12, 2003
Messages
58
Location
The Netherlands
Dear all,

I've just created an application in VB.net 2005. What a GREAT program in comparison with 2003 :). But I have one question.

When I have my windows style "classic" I have the standard grey buttons. When I use windows "XP Style" I have nice rounded buttons in design time, but when running they become square. How can I change this ? I also want nicely shaped buttons in runtime :)

Grtz,
Antoine
 
What do you have the button's FlatStyle property set to?

If you set the flatstyle to 'System' then I believe the button should follow your Windows settings - so if you're using Windows visual styles, then the button should follow the theme, if you're not using visual styles then the button will be the standard grey box.
 
Hello Junkee,

I have Flatstyle.system, that is why I think it is a little strange. Maybe there is something "wrong" in the form. I migrated this project from .NET 2003 maybe there is something wrong. Everything is working fine except for some minor alpha blending things.

Still thanks for your reply ! :)
 
Antione said:
I migrated this project from .NET 2003...
I had a similar experience when I migrated a project from .Net 1.1 to .Net 2.0. I ended up fixing the problem by creating a new solution/project and adding the files to it. My assumption was that there is a setting somewhere that altered the visual styles, or there is a setting that needed to be set that was not set by the conversion wizard. After I re-imported everything, I got the slick XP visual styles.
 
I don't know what particular option you might be losing in the translation, however there are a number of ways to enable visual styles in an application in VB.Net 2005. One way is the .Net 1.1 way, which is to have a sub Main that makes a call to Application.EnableVisualStyles as the very first statement.

Another way is the .Net 1.0 way, which is to include a manifest with your application (an example of such a manifest is available in MSDN for .Net 1.x).

A third way is through the "Application Framework," a feature in VB8 that creates a set of classes for you to manage your application with. Many people prefer not to use the Application Framework (there are plenty of reasons to not want to, for example, if you want to create your own Sub Main, if you don't want all the extra code and resources compiled in to use only one feature of the "Application Framework", or if you want your code to be more portable between languages), but if you don't mind using it go to your project settings, check "Enable Application Framework", and in the "Windows application framework properties" box check "Enable Xp Visual Styles".
 
michaelrawi said:
If your project start from sub main, you have to enable XP visual style by code. Use Application.EnableVisualStyle method before you run your application form
I think I've heard that somewhere before...
 
marble_eater said:
I don't know what particular option you might be losing in the translation,...
I think it just has to do with the fact that you are essentially running .Net 1.1 code in .Net 2.0 without running any of the wizards to setup your project (main, application framework, etc). Whatever code snippets that are required to be present aren't in the name of preserving as much of your converted code as possible. Just a theory.
 
Back
Top