Hola, hoy vengo a pedirles ayuda .
Tome el Tabcontrol, "Chrome69Tabcontrol " , lo pase a vb, y le agregue la posibilidad de arrastrar las pestañas de tabcontrol.
El problema es que quiero que desaparezca los botones de navigacion y no se como hacerlo :

Lo que quiero lograr es yo mismo calcular el tamaño disponible, y auto ajustar el tamaño de las pestañas, asi como lo hace Google Chrome.
Aqui el codigo :
Gracias de antemano.
Tome el Tabcontrol, "Chrome69Tabcontrol " , lo pase a vb, y le agregue la posibilidad de arrastrar las pestañas de tabcontrol.
El problema es que quiero que desaparezca los botones de navigacion y no se como hacerlo :

Lo que quiero lograr es yo mismo calcular el tamaño disponible, y auto ajustar el tamaño de las pestañas, asi como lo hace Google Chrome.
Aqui el codigo :
Código (vbnet) [Seleccionar]
Imports System.Drawing.Drawing2D
Namespace DragonTubeControls
Public Class Helpers
Public Shared Function Base64ToImage(ByVal Base64str As String) As System.Drawing.Image
Dim Fixb64 As String = Base64str.Replace(" ", "+")
Dim MemStream As System.IO.MemoryStream = New System.IO.MemoryStream(Convert.FromBase64String(Fixb64))
Dim ImageStream As Image = System.Drawing.Image.FromStream(MemStream)
MemStream.Close()
Return ImageStream
End Function
End Class
Public Class Chrome69Tabcontrol
Inherits TabControl
#Region " Decalre's "
Private AddImageBlack As String = "iVBORw0KGgoAAAANSUhEUgAAABsAAAAcCAYAAACQ0cTtAAAAN0lEQVR42mNgGAWjYMiCyMiEh3SzLCoq8f+oZaOWgVMdyGBiMU1S6WicjVo2eMrGUTAKRsHgBgBNazNxj/heLwAAAABJRU5ErkJggg=="
Private CloseImageBlack As String = "iVBORw0KGgoAAAANSUhEUgAAAA8AAAAQCAYAAADJViUEAAAAU0lEQVR42mNgGOHA3Nx8FRDboIubmZnZAsVX49UMVfQc2QCo2AsQTdB2mGKQASRpxGIAaRqhfrchSzNU43OQJpKcjayR5AADRRU2RVAD1jCMAgYAuEUszUWy7F8AAAAASUVORK5CYII="
Private predraggedTab As TabPage
Private ReferenceTabSize As New Size(505, 505)
#End Region
Const CLOSE_SIZE As Integer = 16
Public Sub New()
MyBase.New()
SetStyles()
Me.SizeMode = TabSizeMode.Fixed
Me.Dock = DockStyle.Fill
Me.Font = New Font("Microsoft Yahei", 9.0F)
Me.ItemSize = New Size(245, 35)
Me.DoubleBuffered = True
Me.AllowDrop = True
' Me.Multiline = True
' Me.AutoSize = False
End Sub
Private Sub SetStyles()
MyBase.SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
MyBase.UpdateStyles()
End Sub
Public Overrides ReadOnly Property DisplayRectangle As Rectangle
Get
Dim rect As Rectangle = MyBase.DisplayRectangle
Return New Rectangle(rect.Left - 8, rect.Top - 1, rect.Width + 12, rect.Height + 8)
End Get
End Property
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Me.Refresh()
Me.Update()
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
Dim rect As Rectangle = Me.ClientRectangle
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear
Using bufferedGraphics As BufferedGraphics = BufferedGraphicsManager.Current.Allocate(e.Graphics, rect)
bufferedGraphics.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(230, 232, 236)), rect)
For index As Integer = 0 To Me.TabCount - 1
DrawTabPage(bufferedGraphics.Graphics, Me.GetTabRect(index), index)
Next
bufferedGraphics.Render(e.Graphics)
End Using
End Sub
Private Sub DrawTabPage(ByVal graphics As Graphics, ByVal rectangle As Rectangle, ByVal index As Integer)
graphics.SmoothingMode = SmoothingMode.HighQuality
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
' Me.TabPages(index).AutoSize = False
' rectangle.Size = Me.ItemSize
Dim sf As StringFormat = New StringFormat()
sf.Trimming = StringTrimming.EllipsisCharacter
sf.FormatFlags = StringFormatFlags.NoWrap
Dim fontRect As Rectangle = New Rectangle(rectangle.X + 40, rectangle.Y + 7, rectangle.Width, Me.TabPages(index).Font.Height)
Dim rectClose As Rectangle = GetCloseRect(rectangle)
Dim p5 As Point = New Point(rectangle.Left, 7)
Dim p6 As Point = New Point(rectClose.X - 12, 12)
Try
If index = Me.TabCount - 1 Then
Using Add As Bitmap = Helpers.Base64ToImage(AddImageBlack)
graphics.DrawImage(Add, p5)
End Using
Else
If index = Me.SelectedIndex Then
graphics.FillPath(New SolidBrush(Color.FromArgb(255, 255, 255)), CreateTabPath(rectangle))
graphics.DrawString(Me.TabPages(index).Text, Me.TabPages(index).Font, New SolidBrush(Color.SlateGray), fontRect, sf)
If Me.ImageList IsNot Nothing Then
Dim imgindex As Integer = Me.TabPages(index).ImageIndex
Dim key As String = Me.TabPages(index).ImageKey
Dim icon As Image = New Bitmap(32, 32)
If imgindex > -1 Then
icon = Me.ImageList.Images(imgindex)
End If
If Not String.IsNullOrEmpty(key) Then
icon = Me.ImageList.Images(key)
End If
graphics.DrawImage(icon, rectangle.Left + 22, rectangle.Top + 9)
End If
Using Close As Bitmap = Helpers.Base64ToImage(CloseImageBlack)
graphics.DrawImage(Close, p6)
End Using
Else
graphics.FillPath(New SolidBrush(Color.FromArgb(230, 232, 236)), CreateTabPath(rectangle))
graphics.DrawString(Me.TabPages(index).Text, Me.TabPages(index).Font, New SolidBrush(Color.Gray), fontRect, sf)
If Me.ImageList IsNot Nothing Then
Dim imgindex As Integer = Me.TabPages(index).ImageIndex
Dim key As String = Me.TabPages(index).ImageKey
Dim icon As Image = New Bitmap(32, 32)
If imgindex > -1 Then
icon = Me.ImageList.Images(imgindex)
End If
If Not String.IsNullOrEmpty(key) Then
icon = Me.ImageList.Images(key)
End If
graphics.DrawImage(icon, rectangle.Left + 22, rectangle.Top + 9)
End If
Using Close As Bitmap = Helpers.Base64ToImage(CloseImageBlack)
graphics.DrawImage(Close, p6)
End Using
End If
End If
Catch __unusedNullReferenceException1__ As System.NullReferenceException
End Try
End Sub
Protected Overrides Sub OnSelecting(ByVal e As TabControlCancelEventArgs)
If e.TabPageIndex = Me.TabPages.Count - 1 Then e.Cancel = True
End Sub
#Region " Mause Event "
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
If e.Button = MouseButtons.Left AndAlso predraggedTab IsNot Nothing Then
Me.DoDragDrop(predraggedTab, DragDropEffects.Move)
End If
MyBase.OnMouseMove(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
predraggedTab = Nothing
MyBase.OnMouseUp(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
Dim lastIndex As Integer = Me.TabCount - 1
Dim AddImage As Bitmap = Helpers.Base64ToImage(AddImageBlack)
Dim p5 As Point = New Point(Me.GetTabRect(lastIndex).Left, 5)
Dim AddImgRec = New Rectangle(p5, AddImage.Size)
If Me.GetTabRect(lastIndex).Contains(e.Location) Then
If AddImgRec.Contains(e.Location) Then
Me.TabPages.Insert(lastIndex, "Chrome Tab")
Me.SelectedIndex = lastIndex
End If
End If
If e.Button = MouseButtons.Left Then
' Incomplete Bug
' If Not Me.TabCount <= 3 Then
' Dim Xw As Integer = Me.Width / Me.TabCount
' If Xw > 245 Then Xw = 245
' Me.ItemSize = New Size(Me.Width / Me.TabCount, Me.ItemSize.Height)
' End If
Dim x As Integer = e.X, y As Integer = e.Y
Dim myTabRect As Rectangle = Me.GetTabRect(Me.SelectedIndex)
myTabRect.Offset(myTabRect.Width - (CLOSE_SIZE + 23), 5)
myTabRect.Width = CLOSE_SIZE
myTabRect.Height = CLOSE_SIZE
Dim isClose As Boolean = x > myTabRect.X AndAlso x < myTabRect.Right AndAlso y > myTabRect.Y AndAlso y < myTabRect.Bottom
If isClose = True Then
If Me.TabPages.Count > 2 Then
Dim tab As TabPage = Me.SelectedTab
Me.TabPages.Remove(tab)
Me.SelectedTab.Refresh()
Me.SelectedIndex = Me.TabPages.Count - 2
tab.Dispose()
GC.Collect()
GC.WaitForPendingFinalizers()
Else
System.Environment.[Exit](0)
Dispose()
End If
End If
End If
predraggedTab = getPointedTab()
End Sub
#End Region
#Region " Private Methods "
Private Function CreateTabPath(ByVal tabBounds As Rectangle) As GraphicsPath
Dim path As GraphicsPath = New GraphicsPath()
Dim spread, eigth, sixth, quarter As Integer
spread = CInt(Math.Floor(CDec(tabBounds.Height)))
eigth = CInt(Math.Floor(CDec(tabBounds.Height) * 1 / 11))
sixth = CInt(Math.Floor(CDec(tabBounds.Height) * 3 / 10))
quarter = CInt(Math.Floor(CDec(tabBounds.Height) * 2 / 3))
path.AddCurve(New Point() {New Point(tabBounds.X + 2, tabBounds.Bottom + 2), New Point(tabBounds.X + sixth, tabBounds.Bottom - eigth), New Point(tabBounds.X + spread - quarter, tabBounds.Y + eigth), New Point(tabBounds.X + spread, tabBounds.Y)})
path.AddLine(tabBounds.X + spread, tabBounds.Y, tabBounds.Right - spread, tabBounds.Y)
path.AddCurve(New Point() {New Point(tabBounds.Right - spread, tabBounds.Y), New Point(tabBounds.Right - spread + quarter, tabBounds.Y + eigth), New Point(tabBounds.Right - sixth, tabBounds.Bottom - eigth), New Point(tabBounds.Right + 2, tabBounds.Bottom + 2)})
path.CloseFigure()
Return path
End Function
Private Function GetCloseRect(ByVal myTabRect As Rectangle) As Rectangle
myTabRect.Offset(myTabRect.Width - (CLOSE_SIZE + 10), 5)
myTabRect.Width = CLOSE_SIZE
myTabRect.Height = CLOSE_SIZE
Return myTabRect
End Function
#End Region
#Region " Other Events "
Protected Overrides Sub OnDragOver(ByVal drgevent As DragEventArgs)
Dim draggedTab = CType(drgevent.Data.GetData(GetType(TabPage)), TabPage)
Dim pointedTab = getPointedTab()
If ReferenceEquals(draggedTab, predraggedTab) AndAlso pointedTab IsNot Nothing Then
drgevent.Effect = DragDropEffects.Move
If Not ReferenceEquals(pointedTab, draggedTab) Then
Me.ReplaceTabPages(draggedTab, pointedTab)
End If
End If
MyBase.OnDragOver(drgevent)
End Sub
Private Function getPointedTab() As TabPage
For i = 0 To Me.TabPages.Count - 1
If Me.GetTabRect(i).Contains(Me.PointToClient(Cursor.Position)) Then
Return Me.TabPages(i)
End If
Next
Return Nothing
End Function
Private Sub ReplaceTabPages(ByVal Source As TabPage, ByVal Destination As TabPage)
Try
Dim SourceIndex = Me.TabPages.IndexOf(Source)
Dim DestinationIndex = Me.TabPages.IndexOf(Destination)
Me.TabPages(DestinationIndex) = Source
Me.TabPages(SourceIndex) = Destination
If Me.SelectedIndex = SourceIndex Then
Me.SelectedIndex = DestinationIndex
ElseIf Me.SelectedIndex = DestinationIndex Then
Me.SelectedIndex = SourceIndex
End If
Me.Refresh()
Catch ex As Exception
End Try
End Sub
#End Region
End Class
End Namespace
Gracias de antemano.