Antoine Posted September 19, 2006 Posted September 19, 2006 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 Quote
Junkee Posted September 19, 2006 Posted September 19, 2006 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. Quote
Antoine Posted September 19, 2006 Author Posted September 19, 2006 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 ! :) Quote
mskeel Posted September 19, 2006 Posted September 19, 2006 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. Quote
Leaders snarfblam Posted September 19, 2006 Leaders Posted September 19, 2006 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". Quote [sIGPIC]e[/sIGPIC]
michaelrawi Posted September 20, 2006 Posted September 20, 2006 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 Quote
Antoine Posted September 20, 2006 Author Posted September 20, 2006 If your project start from sub main' date=' you have to enable XP visual style by code. Use Application.EnableVisualStyle method before you run your application form[/quote'] Thanks all, this was the solution :) :) Quote
Leaders snarfblam Posted September 20, 2006 Leaders Posted September 20, 2006 If your project start from sub main' date=' you have to enable XP visual style by code. Use Application.EnableVisualStyle method before you run your application form[/quote'] I think I've heard that somewhere before... Quote [sIGPIC]e[/sIGPIC]
mskeel Posted September 20, 2006 Posted September 20, 2006 I don't know what particular option you might be losing in the translation' date='...[/quote']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. Quote
michaelrawi Posted September 21, 2006 Posted September 21, 2006 I think I've heard that somewhere before... Yup. MSDN taught me that, when I was migrating from VB6. I don't know why it must use by code while with form startup, you can directly use visual style . . . Quote
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.