Default XP Theme support?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olsen

    Default XP Theme support?

    I paste the following code into each project to get XP theme support.
    'Add this at the beginning of any program to enable Windows XP Visual Styles
    <System.STAThre ad()> Public Shared Sub Main()
    If OSFeature.Featu re.IsPresent(OS Feature.Themes) Then
    System.Windows. Forms.Applicati on.EnableVisual Styles()
    End If
    Application.DoE vents() 'This must be here, otherwise buttons won't
    stylize
    System.Windows. Forms.Applicati on.Run(New Form1)
    End Sub 'Main

    Is there a way I can set up the VS IDE to automatically put this code in
    each form's code?


  • Ken Tucker [MVP]

    #2
    Re: Default XP Theme support?

    Hi,



    Ken
    ------------------------
    "Terry Olsen" <tolsen64@hotma il.com> wrote in message
    news:Ok3onSC2EH A.1152@TK2MSFTN GP14.phx.gbl...
    I paste the following code into each project to get XP theme support.
    'Add this at the beginning of any program to enable Windows XP Visual Styles
    <System.STAThre ad()> Public Shared Sub Main()
    If OSFeature.Featu re.IsPresent(OS Feature.Themes) Then
    System.Windows. Forms.Applicati on.EnableVisual Styles()
    End If
    Application.DoE vents() 'This must be here, otherwise buttons won't
    stylize
    System.Windows. Forms.Applicati on.Run(New Form1)
    End Sub 'Main

    Is there a way I can set up the VS IDE to automatically put this code in
    each form's code?



    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Default XP Theme support?

      "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=blue]
      >I paste the following code into each project to get XP theme support.
      > 'Add this at the beginning of any program to enable Windows XP Visual
      > Styles
      > <System.STAThre ad()> Public Shared Sub Main()
      > If OSFeature.Featu re.IsPresent(OS Feature.Themes) Then
      > System.Windows. Forms.Applicati on.EnableVisual Styles()
      > End If
      > Application.DoE vents() 'This must be here, otherwise buttons won't
      > stylize
      > System.Windows. Forms.Applicati on.Run(New Form1)
      > End Sub 'Main
      >
      > Is there a way I can set up the VS IDE to automatically put this code in
      > each form's code?[/color]

      You can put the code in your app's main class and don't need it in every
      form.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Jim Burns

        #4
        Re: Default XP Theme support?

        There is a .Manifest you can put in the same Dir as the exe and you will get
        support.
        even better you open the exe in Visual studio and add it as a resources ill
        post the manifest with instructions for both.
        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
        news:uNEWGJE2EH A.2708@TK2MSFTN GP10.phx.gbl...[color=blue]
        > "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=green]
        > >I paste the following code into each project to get XP theme support.
        > > 'Add this at the beginning of any program to enable Windows XP Visual
        > > Styles
        > > <System.STAThre ad()> Public Shared Sub Main()
        > > If OSFeature.Featu re.IsPresent(OS Feature.Themes) Then
        > > System.Windows. Forms.Applicati on.EnableVisual Styles()
        > > End If
        > > Application.DoE vents() 'This must be here, otherwise buttons won't
        > > stylize
        > > System.Windows. Forms.Applicati on.Run(New Form1)
        > > End Sub 'Main
        > >
        > > Is there a way I can set up the VS IDE to automatically put this code in
        > > each form's code?[/color]
        >
        > You can put the code in your app's main class and don't need it in every
        > form.
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
        >
        >[/color]



        Comment

        • Jim Burns

          #5
          Re: Default XP Theme support?

          Windows Forms: XP Theme Support
          Demonstrates how to enables support for XP themes in your application.
          Featured Highlights:
          To enable XP theme support in your application you have to write very little
          code. The main task is to create a manifest file and associate it with your
          application.
          At this point controls that support XP Themes will appear "themed" in your
          application.

          This application displays three tabs that highlight the following:

          Controls that support Visual Themes without any changes to property settings
          Three controls that support visual styles but which are not
          demonstrated on this form are H ScrollBar and
          V ScrollBar, and the TrackBar control.
          Controls that require the flatStyle property to be set to system.
          Certain controls that do not support themes or that have limited support are
          also demonstrated.

          Requirements:
          Microsoft Visual Studio.NET Professional or greater.
          Windows XP Home or Professional

          Running the Sample:
          Simply press F5.

          Note: The application contains only static data and controls as the only
          purpose of this sample is to demonstrate the use of Themes.

          If you want to create your own Windows Forms application here are the steps
          you will have to perform:

          Set each control with a FlatStyle property to FlatStyle.Syste m

          Create a manifest file to bind your app to comctl6. The sample manifest file
          below can be used to bind any app (managed or unmanaged) to comctl6. Just
          copy it to the location of the .exe and rename it to <app
          name>.exe.manif est.

          You must then add a Win32 resource to your application. This is
          accomplished by first opening up the *.exe.

          1. Open your exe in VS (file -> open file)
          2. Right click on it and select add resource
          3. Click "Import..." from the dialog
          4. Select your manifest file
          5. In the "Resource Type" field, enter "RT_MANIFES T"
          6. In the property grid, change the resource ID from "101" to "1".
          7. Save the exe.
          8. Make sure the manifest is keep at the same directory level as the
          executable. (In this How-To it is placed in the bin directory of the
          solution)

          A sample manifest is also included and is named Sample_Manifest .xml.



          Here is the Manifest

          Cut-------------------------------------------------------------------------
          ------------------------------------------------

          <?xml version="1.0" encoding="UTF-8" standalone="yes " ?>
          <assembly xmlns="urn:sche mas-microsoft-com:asm.v1" manifestVersion ="1.0">
          <assemblyIdenti ty version="1.0.0. 0" processorArchit ecture="X86" name="Your
          App name here" type

          ="win32" />
          <description>.N ET control deployment tool</description>
          <dependency>
          <dependentAssem bly>
          <assemblyIdenti ty type="win32" name="Microsoft .Windows.Common-Controls"
          version="6.0.0. 0"

          processorArchit ecture="X86" publicKeyToken= "6595b64144ccf1 df" language="*"
          />
          </dependentAssemb ly>
          </dependency>
          </assembly>

          End
          cut-------------------------------------------------------------------------
          --------------------------------------------

          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:uNEWGJE2EH A.2708@TK2MSFTN GP10.phx.gbl...[color=blue]
          > "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=green]
          > >I paste the following code into each project to get XP theme support.
          > > 'Add this at the beginning of any program to enable Windows XP Visual
          > > Styles
          > > <System.STAThre ad()> Public Shared Sub Main()
          > > If OSFeature.Featu re.IsPresent(OS Feature.Themes) Then
          > > System.Windows. Forms.Applicati on.EnableVisual Styles()
          > > End If
          > > Application.DoE vents() 'This must be here, otherwise buttons won't
          > > stylize
          > > System.Windows. Forms.Applicati on.Run(New Form1)
          > > End Sub 'Main
          > >
          > > Is there a way I can set up the VS IDE to automatically put this code in
          > > each form's code?[/color]
          >
          > You can put the code in your app's main class and don't need it in every
          > form.
          >
          > --
          > M S Herfried K. Wagner
          > M V P <URL:http://dotnet.mvps.org/>
          > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
          >
          >[/color]



          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Default XP Theme support?

            "Jim Burns" <Jim004@comcast .net> schrieb:[color=blue]
            > Windows Forms: XP Theme Support[/color]

            :-)

            Enabling Windows XP Visual Styles for Windows Forms applications
            <URL:http://dotnet.mvps.org/dotnet/faqs/?id=xpvisualsty les&lang=en>

            --
            M S Herfried K. Wagner
            M V P <URL:http://dotnet.mvps.org/>
            V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

            Comment

            • Jim Burns

              #7
              Re: Default XP Theme support?

              Sorry left something out.
              copy the file between the cut and end cut line.
              then past into notepad Save file as "Your app name.exe.manife st"
              you will not get them support in the IDE but you will get it when you run
              your exe.
              on the previous post there were two way to add the file I always add it to
              the exe as a resources this way the end user cant delete it. or if its stand
              alone exe it can be moved to any Dir.and still have theme support.
              ""Jim Burns" <Jim004@comcast .net> wrote in message
              news:pt2dnTqO8c PT3jLcRVn-vQ@comcast.com. ..[color=blue]
              > Windows Forms: XP Theme Support
              > Demonstrates how to enables support for XP themes in your application.
              > Featured Highlights:
              > To enable XP theme support in your application you have to write very[/color]
              little[color=blue]
              > code. The main task is to create a manifest file and associate it with[/color]
              your[color=blue]
              > application.
              > At this point controls that support XP Themes will appear "themed" in your
              > application.
              >
              > This application displays three tabs that highlight the following:
              >
              > Controls that support Visual Themes without any changes to property[/color]
              settings[color=blue]
              > Three controls that support visual styles but which are not
              > demonstrated on this form are H ScrollBar and
              > V ScrollBar, and the TrackBar control.
              > Controls that require the flatStyle property to be set to system.
              > Certain controls that do not support themes or that have limited support[/color]
              are[color=blue]
              > also demonstrated.
              >
              > Requirements:
              > Microsoft Visual Studio.NET Professional or greater.
              > Windows XP Home or Professional
              >
              > Running the Sample:
              > Simply press F5.
              >
              > Note: The application contains only static data and controls as the only
              > purpose of this sample is to demonstrate the use of Themes.
              >
              > If you want to create your own Windows Forms application here are the[/color]
              steps[color=blue]
              > you will have to perform:
              >
              > Set each control with a FlatStyle property to FlatStyle.Syste m
              >
              > Create a manifest file to bind your app to comctl6. The sample manifest[/color]
              file[color=blue]
              > below can be used to bind any app (managed or unmanaged) to comctl6. Just
              > copy it to the location of the .exe and rename it to <app
              > name>.exe.manif est.
              >
              > You must then add a Win32 resource to your application. This is
              > accomplished by first opening up the *.exe.
              >
              > 1. Open your exe in VS (file -> open file)
              > 2. Right click on it and select add resource
              > 3. Click "Import..." from the dialog
              > 4. Select your manifest file
              > 5. In the "Resource Type" field, enter "RT_MANIFES T"
              > 6. In the property grid, change the resource ID from "101" to "1".
              > 7. Save the exe.
              > 8. Make sure the manifest is keep at the same directory level as the
              > executable. (In this How-To it is placed in the bin directory of the
              > solution)
              >
              > A sample manifest is also included and is named Sample_Manifest .xml.
              >
              >
              >
              > Here is the Manifest
              >
              >[/color]
              Cut-------------------------------------------------------------------------[color=blue]
              > ------------------------------------------------
              >
              > <?xml version="1.0" encoding="UTF-8" standalone="yes " ?>
              > <assembly xmlns="urn:sche mas-microsoft-com:asm.v1"[/color]
              manifestVersion ="1.0">[color=blue]
              > <assemblyIdenti ty version="1.0.0. 0" processorArchit ecture="X86"[/color]
              name="Your[color=blue]
              > App name here" type
              >
              > ="win32" />
              > <description>.N ET control deployment tool</description>
              > <dependency>
              > <dependentAssem bly>
              > <assemblyIdenti ty type="win32" name="Microsoft .Windows.Common-Controls"
              > version="6.0.0. 0"
              >
              > processorArchit ecture="X86" publicKeyToken= "6595b64144ccf1 df" language="*"
              > />
              > </dependentAssemb ly>
              > </dependency>
              > </assembly>
              >
              > End
              >[/color]
              cut-------------------------------------------------------------------------[color=blue]
              > --------------------------------------------
              >
              > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
              > news:uNEWGJE2EH A.2708@TK2MSFTN GP10.phx.gbl...[color=green]
              > > "Terry Olsen" <tolsen64@hotma il.com> schrieb:[color=darkred]
              > > >I paste the following code into each project to get XP theme support.
              > > > 'Add this at the beginning of any program to enable Windows XP Visual
              > > > Styles
              > > > <System.STAThre ad()> Public Shared Sub Main()
              > > > If OSFeature.Featu re.IsPresent(OS Feature.Themes) Then
              > > > System.Windows. Forms.Applicati on.EnableVisual Styles()
              > > > End If
              > > > Application.DoE vents() 'This must be here, otherwise buttons won't
              > > > stylize
              > > > System.Windows. Forms.Applicati on.Run(New Form1)
              > > > End Sub 'Main
              > > >
              > > > Is there a way I can set up the VS IDE to automatically put this code[/color][/color][/color]
              in[color=blue][color=green][color=darkred]
              > > > each form's code?[/color]
              > >
              > > You can put the code in your app's main class and don't need it in every
              > > form.
              > >
              > > --
              > > M S Herfried K. Wagner
              > > M V P <URL:http://dotnet.mvps.org/>
              > > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
              > >
              > >[/color]
              >
              >
              >
              >[/color]



              Comment

              • Jim Burns

                #8
                Re: Default XP Theme support?

                I guess I don get it.
                every app done on vb.net ,I've done just gets form support.
                I change the theme on my computer and the apps form changes.

                "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                news:%237TWizI2 EHA.1452@TK2MSF TNGP11.phx.gbl. ..[color=blue]
                > "Jim Burns" <Jim004@comcast .net> schrieb:[color=green]
                > > Windows Forms: XP Theme Support[/color]
                >
                > :-)
                >
                > Enabling Windows XP Visual Styles for Windows Forms applications
                > <URL:http://dotnet.mvps.org/dotnet/faqs/?id=xpvisualsty les&lang=en>
                >
                > --
                > M S Herfried K. Wagner
                > M V P <URL:http://dotnet.mvps.org/>
                > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>[/color]


                Comment

                Working...