[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

VB.net Themeable Groupbox inside UXThemed Tagpage

Paul Trippett

12/14/2004 12:31:00 PM


Hi,

I found some code in C# which I have converted to VB.net in an attempt to
use UXTheme to draw the background of the groupbox "themed". The Groupbox
gets themed corectly however child controls of the groupbox (such as a label)
do not.

If you add a System.Windows.Forms.Label to the themed groupbox then its
normal background is set to some random part of the screen, if you place a
custom label control which has had the onpaint event overridden with: UXtheme
drawing the same happens.

However, if you place a System.Windows.Forms.Lebal control and the custom
label control on the groupbox then the standard control looks messed up as
above and the custom control gets drawn correctly with the themed background.

I have attached the code for the group box, if anyone has any ideas

<code>

Namespace Controls

Public Class GroupBox

Inherits System.Windows.Forms.GroupBox

Public Overrides Property BackColor() As Color
Get
Return MyBase.BackColor
End Get
Set(ByVal Value As Color)
' If (Value.Equals(Color.Transparent) =
True) And (FlatStyle = FlatStyle.System) Then
MyBase.SetStyle(ControlStyles.SupportsTransparentBackColor,
True)
MyBase.SetStyle(ControlStyles.UserPaint, True)
MyBase.BackColor = Value
' End If
End Set
End Property

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If (m.Msg = 20) And (Me.FlatStyle = FlatStyle.System) Then
'MyBase.SetStyle(ControlStyles.SupportsTransparentBackColor,
True)
MyBase.SetStyle(ControlStyles.UserPaint, True)
Dim g As Graphics = Graphics.FromHdcInternal(m.WParam)
'OnPaint(New PaintEventArgs(g, New Rectangle(100, 100,
Width, Height)))

System.Windows.Forms.Themes.UxTheme.DrawThemeParentBackground(Me,
g, New Rectangle(0, 0, Width, Height))
g.Dispose()
'MyBase.SetStyle(ControlStyles.SupportsTransparentBackColor,
False)
MyBase.SetStyle(ControlStyles.UserPaint, False)
Exit Sub
End If
MyBase.WndProc(m)
End Sub

End Class

End Namespace

</code>

Thanks