Disabling visual styles for a specific form/control

Hello!

Is it possible to disable XP themes for a specific form or control in .NET Framework 1.1?

I am developing a custom control and I have no control over the user (if he calls Application.EnableVisualStyles() or not) but I'd still like to be sure that my control is displayed properly.

Best regards!
Marcin

[321 byte] By [MarcinHoppe] at [2007-12-16]
# 1
what do you mean by "no control over the user"?

I think as long as you did not set the flatstyle of the control(like button, etc) to system, the visualstyles will not take effect.

Kitata at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

Yes, as for controls that support the FlatStyle property, you are right.

However, some GUI controls have problems with XP themes (e.g. TabPage) and do not allow me to alter their behaviour and look easily.

Best regards!
Marcin

MarcinHoppe at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
With a little Interop it's no problem. VB example follows:



Friend Declare Unicode Function SetWindowTheme Lib "UxTheme.dll" _
(
ByVal hwnd As IntPtr, _
ByVal pszSubAppName As String, _
ByVal pszSubIdList As String) As Integer

Private Sub EnableVisualStyles(ByVal control As Control)
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
SetWindowTheme(control.Handle,
Nothing, Nothing)
End If
End Sub

Private Sub DisableVisualStyles(ByVal control As Control)
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
SetWindowTheme(control.Handle, "", "")
End If
End Sub


MickDoherty at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...