Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,063 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,748 people online right now. Registration is fast and FREE... Join Now!




XP Style buttons without a manifest file.

 
Reply to this topicStart new topic

XP Style buttons without a manifest file.

jpool
1 Feb, 2008 - 09:33 AM
Post #1

New D.I.C Head
*

Joined: 22 Jan, 2008
Posts: 14

Hi,

I was looking for a way to make my butons, check boxes, radio buttons etc appear like they do in XP, however after searching around i found a way. Using a manifest file. This involved creating the file and adding it to the application and lots of other stuff.

I have found that just by simply adding a simple line of code into the 'Form1' code window it will do it anyway.

When you create a new application the code is as shown below.

Note: This is how it looks when you have "Windows Form Designer generated code" expanded.

CODE


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub



Now by adding:

CODE
Application.EnableVisualStyles()


as shown below:

CODE


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()
        Application.EnableVisualStyles()
        'Add any initialization after the InitializeComponent() call

    End Sub



Provding you have the button Flatstyle set to "System" the controls will be displayed in whatever Theme the person who runs the .exe has set.

Now i may be stating the obvious and this is most likely the way to do it, but after searching around playing round with manifest files, (which worked) this seems like a much simpler option.

Can someone please correct me if i am wrong or if there are any flaws in this process.

Go easy, i'm a newbie.

Thanks.

This post has been edited by Martyr2: 1 Feb, 2008 - 11:38 AM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: XP Style Buttons Without A Manifest File.
1 Feb, 2008 - 11:42 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
It is fine to use that, but keep in mind that it is only for operating systems that support it. Basically XP and Windows Server machines. I do not believe it will work for 2000/98 (not 100% sure on 2000). Some people have opted to just leave out that feature so it will be the same look across all platforms.

But it certainly will work. Enjoy! smile.gif
User is online!Profile CardPM
+Quote Post

jpool
RE: XP Style Buttons Without A Manifest File.
1 Feb, 2008 - 12:05 PM
Post #3

New D.I.C Head
*

Joined: 22 Jan, 2008
Posts: 14

Thanks a lot Martyr2 smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:39PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month