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.Ena bleVisualStyles does the trick.
(EnableVisualSt yles 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:
Here's a (poorly) translated version:
(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 ActivateWindowT heme 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 DeactivateWindo wTheme Lib "uxtheme" Alias
"SetWindowTheme " ( _
ByVal hWnd As IntPtr, _
Optional ByRef pszSubAppName As String = " ", _
Optional ByRef pszSubIdList As String = " ") _
As Integer
Private Declare Sub InitCommonContr ols Lib "comctl32" ()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent() call
Call InitCommonContr ols()
Dim Result As Integer = ActivateWindowT heme(Button1.Ha ndle)
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.Ena bleVisualStyles does the trick.
(EnableVisualSt yles 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:
Here's a (poorly) translated version:
(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 ActivateWindowT heme 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 DeactivateWindo wTheme Lib "uxtheme" Alias
"SetWindowTheme " ( _
ByVal hWnd As IntPtr, _
Optional ByRef pszSubAppName As String = " ", _
Optional ByRef pszSubIdList As String = " ") _
As Integer
Private Declare Sub InitCommonContr ols Lib "comctl32" ()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent() call
Call InitCommonContr ols()
Dim Result As Integer = ActivateWindowT heme(Button1.Ha ndle)
Debug.WriteLine (Result)
End Sub
Comment