This snippet shows how to develop a custom panel which is semi transparent by overriding CreateParams and the OnPaint method of the Panel control.
xPanel
Imports System.Windows.Forms
Public Class xPanel
Inherits Panel
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams
cp = MyBase.CreateParams
cp.ExStyle = &H20
Return cp
End Get
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(128, 0, 0, 0)), Me.ClientRectangle)
End Sub
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
MyBase.OnSizeChanged(e)
End Sub
End Class
1 comment:
This code example gives me the desired transparency affect that I am looking for, but when I try and move the control around the screen, the panel seems to disappear. Is there any way around this issue?
Post a Comment