[.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)-VBForums
Results 1 to 6 of 6

Thread: [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

  1. #1

    Thread Starter
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

    Fairly simple, using the SetWindowTheme API call you can change the appearance of a couple controls so that they look a bit nicer:

    Before:
    Name:  SetWindowTheme_Before.png
Views: 1305
Size:  32.2 KB

    After:
    Name:  SetWindowTheme_After.png
Views: 1311
Size:  28.7 KB

    Code:
    Code:
    Public Class UnsafeNativeMethods
    
        '//the character set needs to be Unicode
        <DllImport("uxtheme.dll", CharSet:=CharSet.Unicode)> _
        Friend Shared Function SetWindowTheme(ByVal hWnd As IntPtr, _
                                              ByVal pszSubAppName As String, _
                                              ByVal pszSubIdList As String) As Integer
        End Function
    
    End Class
    Example implementation:

    Code:
    ''' <summary>
    ''' Applies the explorer theme to the specified control.
    ''' </summary>
    ''' <param name="control">Indicates the control to apply the theme to.</param>
    Public Function ApplyTheme(ByVal control As Control) As Integer
        Return Me.ApplyTheme(control, "Explorer")
    End Function
    
    Private Function ApplyTheme(ByVal control As Control, ByVal theme As String) As Integer
        Try
            If control IsNot Nothing Then
                If control.IsHandleCreated Then
                    Return UnsafeNativeMethods.SetWindowTheme(control.Handle, theme, Nothing)
                End If
            End If
        Catch ex As DllNotFoundException
            Return -1
        End Try
        Return -1
    End Function
    
    ''' <summary>
    ''' Clears the applied theme from the specified control.
    ''' </summary>
    ''' <param name="control">Indicates the control to clear the theme from.</param>
    Public Function ClearTheme(ByVal control As Control) As Integer
        Return Me.ApplyTheme(control, String.Empty)
    End Function
    Last edited by ForumAccount; Jul 8th, 2011 at 12:26 PM. Reason: Applied different styling

  2. #2
    Lively Member cevem's Avatar
    Join Date
    Feb 2010
    Location
    Mars
    Posts
    75

    Re: [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

    It's cool. Thank you.

  3. #3
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Location
    On the Internet
    Posts
    3,216

    Re: [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

    Good find there FA; gonna end up using this in my program

  4. #4

    Thread Starter
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

    Quote Originally Posted by formlesstree4 View Post
    Good find there FA; gonna end up using this in my program
    Yeah, it's for sure a nice little aesthetic thing you can do.

  5. #5
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,823

    Re: [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

    Is there a way to get this to work for ContextMenus? Or do I need to write another renderer?

  6. #6
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    3,811

    Re: [.NET 1.0+] Explorer Themed Controls (Windows Aero Visuals)

    Quote Originally Posted by minitech View Post
    Is there a way to get this to work for ContextMenus? Or do I need to write another renderer?
    Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.