对不起,这个非常混乱的标题,这是我的问题。我有一个自定义的 GroupBox,里面是一个自定义的图片框和标签。
问题是,当我在鼠标进入 GroupBox 时启动表单应用程序时,我的标签字体颜色变为黑色,并且我的图片框似乎“消失”了。我不知道为什么会这样。
组框:
Class GhostGroupBox
Inherits ThemeControl154
Sub New()
MyBase.New()
SetStyle(ControlStyles.ResizeRedraw, True)
SetStyle(ControlStyles.ContainerControl, True)
DoubleBuffered = True
BackColor = Color.Transparent
End Sub
Protected Overrides Sub ColorHook()
End Sub
Protected Overrides Sub PaintHook()
G.Clear(Color.FromArgb(60, 60, 60))
Dim asdf As HatchBrush
asdf = New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(35, Color.Black), Color.FromArgb(0, Color.Gray))
G.FillRectangle(New SolidBrush(Color.FromArgb(60, 60, 60)), New Rectangle(0, 0, Width, Height))
asdf = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.DimGray)
G.FillRectangle(asdf, 0, 0, Width, Height)
G.FillRectangle(New SolidBrush(Color.FromArgb(230, 20, 20, 20)), 0, 0, Width, Height)
G.FillRectangle(New SolidBrush(Color.FromArgb(70, Color.Black)), 1, 1, Width - 2, Me.CreateGraphics.MeasureString(Text, Font).Height + 8)
G.DrawLine(New Pen(Color.FromArgb(90, 90, 90)), 1, Me.CreateGraphics.MeasureString(Text, Font).Height + 8, Width - 2, Me.CreateGraphics.MeasureString(Text, Font).Height + 8)
DrawBorders(Pens.Black)
DrawBorders(New Pen(Color.FromArgb(90, 90, 90)), 1)
G.DrawString(Text, Font, Brushes.White, 5, 5)
End Sub
End Class
标签和图片框(相同的代码,只是继承各自的):
Public Class TransparentLabel
Inherits Label
Public Sub New()
Me.SetStyle(ControlStyles.Opaque, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False)
End Sub
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim parms As CreateParams = MyBase.CreateParams
parms.ExStyle = parms.ExStyle Or &H20
' Turn on WS_EX_TRANSPARENT
Return parms
End Get
End Property
End Class
有人能看出有什么问题吗?我尝试将 ControlBox 的 OnMouseMove 注释掉,但没有解决。我也没有为 ControlBox 设置任何事件。