R
Robert Jacobson
Hi,
I'm develing a COM add-in for Microsoft Word XP that displays a form. I'd
like to have the form display using the Windows XP theme. However, neither
using a manifest nor calling Application.EnableVisualStyles does the trick.
(EnableVisualStyles works but massive instability, probably because the
system is trying to theme the Word application itself.)
I'm now trying to selectively enable the themes for just my form, or just
certain elements on my form, by using the SetWindowTheme api. My
understanding is that SetWindowTheme doesn't need a manifest to work. (MSDN
isn't particularly clear.)
Herfried posted an article that discussed using this function with VB6:
http://www.activevb.de/tutorials/tut_xpstyles/xpstyles.html
Here's a (poorly) translated version:
http://translate.google.com/transla...ivevb.de/tutorials/tut_xpstyles/xpstyles.html
(You gotta love using the "Communist manifesto" in Visual Basic. <g>)
I created a test WinForms app that contains just a simple form with a
button. In the code below, I'm trying to theme the button. The function is
returning a 0 (success?) but still appears in the classic style. It happens
regardless of whether the button has "Standard" or "System" FlatStyle.
Any suggestions?
Thanks,
Robert Jacobson
Private Declare Function ActivateWindowTheme Lib "uxtheme" Alias
"SetWindowTheme" ( _
ByVal hWnd As IntPtr, _
Optional ByVal pszSubAppName As Integer = 0, _
Optional ByVal pszSubIdList As Integer = 0) _
As Integer
Private Declare Function DeactivateWindowTheme Lib "uxtheme" Alias
"SetWindowTheme" ( _
ByVal hWnd As IntPtr, _
Optional ByRef pszSubAppName As String = " ", _
Optional ByRef pszSubIdList As String = " ") _
As Integer
Private Declare Sub InitCommonControls Lib "comctl32" ()
#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
Call InitCommonControls()
Dim Result As Integer = ActivateWindowTheme(Button1.Handle)
Debug.WriteLine(Result)
End Sub
I'm develing a COM add-in for Microsoft Word XP that displays a form. I'd
like to have the form display using the Windows XP theme. However, neither
using a manifest nor calling Application.EnableVisualStyles does the trick.
(EnableVisualStyles works but massive instability, probably because the
system is trying to theme the Word application itself.)
I'm now trying to selectively enable the themes for just my form, or just
certain elements on my form, by using the SetWindowTheme api. My
understanding is that SetWindowTheme doesn't need a manifest to work. (MSDN
isn't particularly clear.)
Herfried posted an article that discussed using this function with VB6:
http://www.activevb.de/tutorials/tut_xpstyles/xpstyles.html
Here's a (poorly) translated version:
http://translate.google.com/transla...ivevb.de/tutorials/tut_xpstyles/xpstyles.html
(You gotta love using the "Communist manifesto" in Visual Basic. <g>)
I created a test WinForms app that contains just a simple form with a
button. In the code below, I'm trying to theme the button. The function is
returning a 0 (success?) but still appears in the classic style. It happens
regardless of whether the button has "Standard" or "System" FlatStyle.
Any suggestions?
Thanks,
Robert Jacobson
Private Declare Function ActivateWindowTheme Lib "uxtheme" Alias
"SetWindowTheme" ( _
ByVal hWnd As IntPtr, _
Optional ByVal pszSubAppName As Integer = 0, _
Optional ByVal pszSubIdList As Integer = 0) _
As Integer
Private Declare Function DeactivateWindowTheme Lib "uxtheme" Alias
"SetWindowTheme" ( _
ByVal hWnd As IntPtr, _
Optional ByRef pszSubAppName As String = " ", _
Optional ByRef pszSubIdList As String = " ") _
As Integer
Private Declare Sub InitCommonControls Lib "comctl32" ()
#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
Call InitCommonControls()
Dim Result As Integer = ActivateWindowTheme(Button1.Handle)
Debug.WriteLine(Result)
End Sub