⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabcontrol.vb

📁 VB.NET的Web浏览器IE7的克隆选项卡式浏览器 描述:这是一个例子写的vb.net浏览器使用的。 NET Framework 2.0 ( Visual Studio 2005中) 。这是一个
💻 VB
📖 第 1 页 / 共 5 页
字号:

        Protected Overrides Sub OnClearComplete()
            MyBase.OnClearComplete()
            TabControl.pnlBottom.Controls.Clear()
            TabControl.pnlTabs.Controls.Clear()
        End Sub

        <Description("Returns the selected TabPage.")> _
        Public Function SelectedTab() As TabPage
            For Each T As TabPage In List
                If T.IsSelected Then Return T
            Next
            Return Nothing
        End Function

        <Description("Returns the index of the selected TabPage.")> _
        Public Function SelectedIndex() As Integer
            For Each T As TabPage In List
                If T.IsSelected Then Return List.IndexOf(T)
            Next
        End Function

        Private Sub TabPage_Clicked(ByVal sender As Object, ByVal e As EventArgs)
            TabControl.SelectItem(sender)
            RaiseEvent SelectedChanged(sender, e)
        End Sub

        Private Sub TabPage_Closed(ByVal sender As Object, ByVal e As EventArgs)
            Remove(sender)
        End Sub

        Private Sub TabPage_GetTabRegion(ByVal sender As Object, ByVal e As TabControl.GetTabRegionEventArgs)
            RaiseEvent GetTabRegion(sender, e)
        End Sub

        Private Sub TabPage_TabPaintBackground(ByVal sender As Object, ByVal e As TabControl.TabPaintEventArgs)
            RaiseEvent TabPaintBackground(sender, e)
        End Sub

        Private Sub TabPage_TabPaintBorder(ByVal sender As Object, ByVal e As TabControl.TabPaintEventArgs)
            RaiseEvent TabPaintBorder(sender, e)
        End Sub

        Private Sub TabPage_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
            TabControl.ArrangeItems()
        End Sub

        Private Sub TabPage_Draging(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
            If TabControl.AllowTabReorder AndAlso e.Button = Windows.Forms.MouseButtons.Left Then
                Dim t As TabPage = GetTabPage(DirectCast(sender, TabPage), e.X, e.Y)
                If t IsNot Nothing Then
                    ' swap the tabpages
                    IndexOf(t) = IndexOf(DirectCast(sender, TabPage))
                End If
            End If
        End Sub

        Private Function GetTabPage(ByVal TabPage As TabPage, ByVal x As Integer, ByVal y As Integer) As TabPage
            For i As Integer = 0 To List.Count - 1
                If DirectCast(List(i), TabPage) IsNot TabPage AndAlso DirectCast(List(i), TabPage).TabVisible Then
                    If DirectCast(List(i), TabPage).RectangleToScreen(DirectCast(List(i), TabPage).ClientRectangle).Contains(TabPage.PointToScreen(New Point(x, y))) Then
                        Return DirectCast(List(i), TabPage)
                    End If
                End If
            Next
            Return Nothing
        End Function

        Sub TabPage_Enter(ByVal sender As Object, ByVal e As EventArgs)
            If Not TabControl.m_Focused Then
                TabControl.SetFocus = True
            End If
        End Sub

        Sub TabPage_Leave(ByVal sender As Object, ByVal e As EventArgs)
            If TabControl.m_Focused Then
                TabControl.SetFocus = False
            End If
        End Sub

    End Class

#End Region

    <Description("Gets or sets the specified alignment for the control.")> _
    Public Enum TabAlignment
        Top = 0
        Bottom = 1
    End Enum

    <Description("Gets or sets the specified direction for the control.")> _
    Public Enum FlowDirection
        LeftToRight = 0
        RightToLeft = 2
    End Enum

    Public Enum Weight
        Soft = 2
        Medium = 3
        Strong = 4
        Strongest = 5
    End Enum

    Private AddingPage As Boolean = False
    Private LeftOffset As Integer = 3
    Private IsDelete As Boolean = False
    Private Background As New System.Windows.Forms.Panel
    Private WithEvents Items As New TabPageCollection(Me)
    Private m_TabsDirection As FlowDirection = FlowDirection.LeftToRight
    Private m_TabMaximumWidth As Integer = 200
    Private m_tabMinimumWidth As Integer = 100
    Private m_BackLowColor As Color
    Private m_BackHighColor As Color
    Private m_BorderColor As Color
    Private m_TabBackHighColor As Color
    Private m_TabBackLowColor As Color
    Private m_TabBackHighColorDisabled As Color
    Private m_TabBackLowColorDisabled As Color
    Private m_BorderColorDisabled As Color
    Private m_ForeColorDisabled As Color
    Private m_TopSeparator As Boolean = True
    Private m_TabTop As Integer = 3
    Private m_TabHeight As Integer = 28
    Private m_TabOffset As Integer = 3
    Private m_TabPadLeft As Integer = 5
    Private m_TabPadRight As Integer = 5
    Private m_TabSmoothingMode = Drawing2D.SmoothingMode.None
    Private m_TabIconSize As Size = New Size(16, 16)
    Private m_Alignment As TabAlignment = TabAlignment.Top
    Private m_FontBoldOnSelect As Boolean = True
    Private m_HotTrack As Boolean = True
    Private m_TabCloseButtonSize As Size = New Size(17, 17)
    Private m_TabCloseButtonVisible As Boolean = True
    Private m_TabCloseButtonImage As Image
    Private m_TabCloseButtonImageHot As Image
    Private m_TabCloseButtonImageDisabled As Image
    Private m_TabCloseButtonBackHighColor As Color
    Private m_TabCloseButtonBackLowColor As Color
    Private m_TabCloseButtonBorderColor As Color
    Private m_TabCloseButtonForeColor As Color
    Private m_TabCloseButtonBackHighColorDisabled As Color
    Private m_TabCloseButtonBackLowColorDisabled As Color
    Private m_TabCloseButtonBorderColorDisabled As Color
    Private m_TabCloseButtonForeColorDisabled As Color
    Private m_TabCloseButtonBackHighColorHot As Color
    Private m_TabCloseButtonBackLowColorHot As Color
    Private m_TabCloseButtonBorderColorHot As Color
    Private m_TabCloseButtonForeColorHot As Color
    Private m_AllowTabReorder As Boolean = True
    Private m_TabGlassGradient As Boolean = False
    Private m_TabBorderEnhanced As Boolean = False
    Private m_RenderMode As ToolStripRenderMode
    Private m_ContextMenuRenderer As ToolStripRenderer
    Private m_TabBorderEnhanceWeight As Weight = Weight.Medium
    Private m_Focused As Boolean

    Friend Shadows ReadOnly defaultPadding As Padding = New Padding(0, 0, 0, 0)
    Friend ReadOnly defaultBackLowColor As Color = SystemColors.ControlLightLight
    Friend ReadOnly defaultBackHighColor As Color = SystemColors.Control
    Friend ReadOnly defaultBorderColor As Color = SystemColors.ControlDarkDark
    Friend ReadOnly defaultTabBackHighColor As Color = SystemColors.Window
    Friend ReadOnly defaultTabBackLowColor As Color = SystemColors.Control
    Friend ReadOnly defaultTabBackHighColorDisabled As Color = SystemColors.Control
    Friend ReadOnly defaultTabBackLowColorDisabled As Color = SystemColors.ControlDark
    Friend ReadOnly defaultBorderColorDisabled As Color = SystemColors.ControlDark
    Friend ReadOnly defaultForeColorDisabled As Color = SystemColors.ControlText
    Friend ReadOnly defaultControlButtonBackHighColor As Color = SystemColors.GradientInactiveCaption
    Friend ReadOnly defaultControlButtonBackLowColor As Color = SystemColors.GradientInactiveCaption
    Friend ReadOnly defaultControlButtonBorderColor As Color = SystemColors.HotTrack
    Friend ReadOnly defaultControlButtonForeColor As Color = SystemColors.ControlText
    Friend ReadOnly defaultTabCloseButtonSize As Size = New Size(17, 17)
    Friend ReadOnly defaultTabIconSize As Size = New Size(16, 16)
    Friend ReadOnly defaultTabCloseButtonBackHighColor As Color = System.Drawing.Color.IndianRed
    Friend ReadOnly defaultTabCloseButtonBackHighColorDisabled As Color = System.Drawing.Color.LightGray
    Friend ReadOnly defaultTabCloseButtonBackHighColorHot As Color = System.Drawing.Color.LightCoral
    Friend ReadOnly defaultTabCloseButtonBackLowColor As Color = System.Drawing.Color.Firebrick
    Friend ReadOnly defaultTabCloseButtonBackLowColorDisabled As Color = System.Drawing.Color.DarkGray
    Friend ReadOnly defaultTabCloseButtonBackLowColorHot As Color = System.Drawing.Color.IndianRed
    Friend ReadOnly defaultTabCloseButtonBorderColor As Color = System.Drawing.Color.DarkRed
    Friend ReadOnly defaultTabCloseButtonBorderColorDisabled As Color = System.Drawing.Color.Gray
    Friend ReadOnly defaultTabCloseButtonBorderColorHot As Color = System.Drawing.Color.Firebrick
    Friend ReadOnly defaultTabCloseButtonForeColor As Color = System.Drawing.Color.White
    Friend ReadOnly defaultTabCloseButtonForeColorDisabled As Color = System.Drawing.Color.White
    Friend ReadOnly defaultTabCloseButtonForeColorHot As Color = System.Drawing.Color.White
    Friend ReadOnly defaultRenderMode As ToolStripRenderMode = ToolStripRenderMode.ManagerRenderMode

    <Description("Occurs when the Tab Page requests the tab region.")> _
    Public Event GetTabRegion(ByVal sender As Object, ByVal e As GetTabRegionEventArgs)
    <Description("Occurs when the Tab Background has been painted.")> _
    Public Event TabPaintBackground(ByVal sender As Object, ByVal e As TabPaintEventArgs)
    <Description("Occurs when the Tab Border has been painted.")> _
    Public Event TabPaintBorder(ByVal sender As Object, ByVal e As TabPaintEventArgs)
    <Description("Occurs when the TabControl Focus changes.")> _
    Public Event FocusedChanged As EventHandler
    Public Event SelectedTabChanged As EventHandler

    Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        Me.SuspendLayout()
        'Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
        'Me.SetStyle(ControlStyles.UserPaint, True)
        Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
        Background.BackColor = SystemColors.AppWorkspace
        Background.BorderStyle = Windows.Forms.BorderStyle.Fixed3D
        Background.Dock = DockStyle.Fill
        Me.Controls.Add(Background)
        Background.BringToFront()
        ResetBackLowColor()
        ResetBackHighColor()
        ResetBorderColor()
        ResetTabBackHighColor()
        ResetTabBackLowColor()
        ResetTabBackHighColorDisabled()
        ResetTabBackLowColorDisabled()
        ResetBorderColorDisabled()
        ResetForeColorDisabled()
        ResetControlButtonBackHighColor()
        ResetControlButtonBackLowColor()
        ResetControlButtonBorderColor()
        ResetControlButtonForeColor()
        ResetTabCloseButtonBackHighColor()
        ResetTabCloseButtonBackLowColor()
        ResetTabCloseButtonBorderColor()
        ResetTabCloseButtonForeColor()
        ResetTabCloseButtonBackHighColorDisabled()
        ResetTabCloseButtonBackLowColorDisabled()
        ResetTabCloseButtonBorderColorDisabled()
        ResetTabCloseButtonForeColorDisabled()
        ResetTabCloseButtonBackHighColorHot()
        ResetTabCloseButtonBackLowColorHot()
        ResetTabCloseButtonBorderColorHot()
        ResetTabCloseButtonForeColorHot()
        ResetPadding()
        ResetTabCloseButtonSize()
        ResetTabIconSize()
        ResetRenderMode()
        AdjustHeight()
        DropButton.RenderMode = Me.RenderMode
        CloseButton.RenderMode = Me.RenderMode
        Me.ResumeLayout()
    End Sub

    <Browsable(False)> _
    Public Overrides ReadOnly Property Focused() As Boolean
        Get
            Return m_Focused
        End Get
    End Property

    Friend WriteOnly Property SetFocus() As Boolean
        Set(ByVal value As Boolean)
            m_Focused = value
            RaiseEvent FocusedChanged(Me, New EventArgs)
        End Set
    End Property

    <Browsable(False)> _
    Public ReadOnly Property SelectedForm() As Object
        Get
            If pnlBottom.Controls.Count > 0 Then
                Return pnlBottom.Controls(0)
            Else
                Return Nothing
            End If
        End Get
    End Property

    <Browsable(True), Category("Layout"), DefaultValue(FlowDirection.LeftToRight), Description("Gets or sets the the direction which the tabs are drawn.")> _
    Public Property TabsDirection() As FlowDirection
        Get
            Return m_TabsDirection
        End Get
        Set(ByVal value As FlowDirection)
            m_TabsDirection = value
            SelectItem(Nothing)
        End Set
    End Property

    <Browsable(True), Category("Appearance"), DefaultValue(False), Description("Gets or sets if the tab background will paint with glass style.")> _
    Public Property TabGlassGradient() As Boolean
        Get
            Return m_TabGlassGradient
        End Get
        Set(ByVal Value As Boolean)
            m_TabGlassGradient = Value
            For Each t As TabPage In TabPages
                t.GlassGradient = Value
            Next
        End Set
    End Property

    <Browsable(True), Category("Appearance"), DefaultValue(False), Description("Gets or sets if the tab border will paint with enhanced style.")> _
    Public Property TabBorderEnhanced() As Boolean
        Get
            Return m_TabBorderEnhanced
        End Get
        Set(ByVal Value As Boolean)
            m_TabBorderEnhanced = Value
            For Each t As TabPage In TabPages
                t.BorderEnhanced = Value
            Next
        End Set
    End Property

    <Browsable(True), Category("Appearance"), Description("Gets or sets the System.Drawing.Color structure that represents the starting color of the Background linear gradient for the tab close button.")> _
    Public Property TabCloseButtonBackHighColor() As System.Drawing.Color
        Get
            Return m_TabCloseButtonBackHighColor
        End Get
        Set(ByVal Value As Color)
            m_TabCloseButtonBackHighColor = Value
        End Set
    End Property

    Friend Function ShouldSerializeTabCloseButtonBackHighColor() As Boolean
        Return m_TabCloseButtonBackHighColor <> Me.defaultTabCloseButtonBackHighColor

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -