Never Mind- Found the Answer. In the OnPaint() Sub, write
g.Clear(Color.Black)
this paints the background black, so the glass effects show
Pregunta
In my app, I would like to have my tabcontrol have an aero effect on the header. This works with the normal winforms tabcontrol using this code:
Imports System.Runtime.InteropServices
<DllImport("dwmapi.dll")> _
Private Shared Function DwmExtendFrameIntoClientArea(ByVal hwnd As IntPtr, ByRef pMarInset As MARGINS) As Integer
End Function
<StructLayout(LayoutKind.Sequential)> _
Private Structure MARGINS
Public cxLeftWidth As Integer
Public cxRightWidth As Integer
Public cyTopHeight As Integer
Public cyBottomHeight As Integer
End Structure
Problem is, I have a custom tabcontrol class (the actual one is much larger and has a much more complicated OnPaint() override than below)
Public Class CustomTab
Inherits TabControl
Public Sub New()
SetStyle(ControlStyles.UserPaint or ControlStyles.ResizeRedraw,True)
End Sub
Protected Overrides Sub OnPaint(e as PaintEventArgs)
Dim g as Graphics = e.Graphics
Dim r as Rectangle
For i=0 to TabCount - 1
If i = SelectedIndex
r = GetTabRect(i)
g.FillRectangle(New SolidBrush(My.Settings.TabColor),r)
Else
r = GetTabRect(i)
g.FillRectangle(New SolidBrush(SystemColors.Control),r)
End If
Next
End Sub
End Class
When I try the glass effects with this, it does not show in the header like normal. Does anyone know why the Userdrawn tabcontrol will not have the transparent header?
Working (Normal tabcontrol):
Not working (my tabcontrol):
Solución
Never Mind- Found the Answer. In the OnPaint() Sub, write
g.Clear(Color.Black)
this paints the background black, so the glass effects show