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

📄 tabpage.vb

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

    Public Property CloseButtonBackHighColorDisabled() As System.Drawing.Color
        Get
            Return m_CloseButtonBackHighColorDisabled
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonBackHighColorDisabled = Value
        End Set
    End Property

    Public Property CloseButtonBackLowColorDisabled() As System.Drawing.Color
        Get
            Return m_CloseButtonBackLowColorDisabled
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonBackLowColorDisabled = Value
        End Set
    End Property

    Public Property CloseButtonBorderColorDisabled() As System.Drawing.Color
        Get
            Return m_CloseButtonBorderColorDisabled
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonBorderColorDisabled = Value
        End Set
    End Property

    Public Property CloseButtonForeColorDisabled() As System.Drawing.Color
        Get
            Return m_CloseButtonForeColorDisabled
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonForeColorDisabled = Value
        End Set
    End Property

    Public Property CloseButtonBackHighColorHot() As System.Drawing.Color
        Get
            Return m_CloseButtonBackHighColorHot
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonBackHighColorHot = Value
        End Set
    End Property

    Public Property CloseButtonBackLowColorHot() As System.Drawing.Color
        Get
            Return m_CloseButtonBackLowColorHot
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonBackLowColorHot = Value
        End Set
    End Property

    Public Property CloseButtonBorderColorHot() As System.Drawing.Color
        Get
            Return m_CloseButtonBorderColorHot
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonBorderColorHot = Value
        End Set
    End Property

    Public Property CloseButtonForeColorHot() As System.Drawing.Color
        Get
            Return m_CloseButtonForeColorHot
        End Get
        Set(ByVal Value As Color)
            m_CloseButtonForeColorHot = Value
        End Set
    End Property

    Friend Property HotTrack() As Boolean
        Get
            Return m_HotTrack
        End Get
        Set(ByVal value As Boolean)
            m_HotTrack = value
            Invalidate()
        End Set
    End Property

    Friend Property CloseButtonSize() As Size
        Get
            Return m_CloseButtonSize
        End Get
        Set(ByVal value As Size)
            m_CloseButtonSize = value
            CalculateWidth()
            Invalidate()
        End Set
    End Property

    Friend Property FontBoldOnSelect() As Boolean
        Get
            Return m_FontBoldOnSelect
        End Get
        Set(ByVal value As Boolean)
            m_FontBoldOnSelect = value
            CalculateWidth()
            Invalidate()
        End Set
    End Property

    Friend Property IconSize() As Size
        Get
            Return m_IconSize
        End Get
        Set(ByVal value As Size)
            m_IconSize = value
            CalculateWidth()
            Invalidate()
        End Set
    End Property

    Friend Property SmoothingMode() As SmoothingMode
        Get
            Return m_SmoothingMode
        End Get
        Set(ByVal value As SmoothingMode)
            m_SmoothingMode = value
            Invalidate()
        End Set
    End Property

    Friend Property Alignment() As TabControl.TabAlignment
        Get
            Return m_Alignment
        End Get
        Set(ByVal value As TabControl.TabAlignment)
            m_Alignment = value
            Invalidate()
        End Set
    End Property

    Friend Property GlassGradient() As Boolean
        Get
            Return m_GlassGradient
        End Get
        Set(ByVal value As Boolean)
            m_GlassGradient = value
        End Set
    End Property

    Friend Property BorderEnhanced() As Boolean
        Get
            Return m_BorderEnhanced
        End Get
        Set(ByVal value As Boolean)
            m_BorderEnhanced = value
        End Set
    End Property

    Friend Property RenderMode() As ToolStripRenderMode
        Get
            Return m_RenderMode
        End Get
        Set(ByVal value As ToolStripRenderMode)
            m_RenderMode = value
            Invalidate()
        End Set
    End Property

    Friend Property BorderEnhanceWeight() As TabControl.Weight
        Get
            Return m_BorderEnhanceWeight
        End Get
        Set(ByVal value As TabControl.Weight)
            m_BorderEnhanceWeight = value
        End Set
    End Property

    Public Property Icon() As Icon
        Get
            Return m_Form.Icon
        End Get
        Set(ByVal value As Icon)
            m_Form.Icon = value
            Dim r As New Region(New Rectangle(PadLeft, (Me.Height / 2 - m_IconSize.Height / 2), m_IconSize.Width, m_IconSize.Height))
            Me.Invalidate(r)
            r.Dispose()
            r = Nothing
            MenuItem.Image = value.ToBitmap
        End Set
    End Property

    <Description("Selects the TabPage.")> _
    Public Shadows Sub [Select]()
        If Not IsSelected Then
            RaiseEvent Click(Me, New EventArgs)
        End If
    End Sub

    Private Function CreateGradientBrush(ByVal Rectangle As Rectangle, ByVal Color1 As Color, ByVal Color2 As Color) As Drawing2D.LinearGradientBrush
        If m_GlassGradient Then
            Return Helper.CreateGlassGradientBrush(Rectangle, Color1, Color2)
        Else
            Return New Drawing2D.LinearGradientBrush(Rectangle, Color1, Color2, Drawing2D.LinearGradientMode.Vertical)
        End If
    End Function

    Private Sub TabContents_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_Form.Enter
        RaiseEvent EnterForm(Me, e)
    End Sub

    Private Sub TabContent_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles m_Form.FormClosed
        ' if the form is closed closes the tabpage
        RaiseEvent Close(Me, New EventArgs)
    End Sub

    Private Sub m_Form_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_Form.Leave
        RaiseEvent LeaveForm(Me, e)
    End Sub

    Private Sub TabContent_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_Form.TextChanged
        CalculateWidth()
        Invalidate()
        MenuItem.Text = m_Form.Text
    End Sub

    Private Sub Tab_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        If m_Selected And Not (MouseOverCloseButton And m_CloseButtonVisible) Then Exit Sub
        If e.Button = Windows.Forms.MouseButtons.Left Then
            ' Close button was clicked
            If MouseOverCloseButton And m_CloseButtonVisible Then
                ' try to close the form
                m_Form.Close()
            Else ' tab was clicked
                ' select the tab
                [Select]()
            End If
        End If
    End Sub

    Private Sub Tab_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
        If m_Selected Then Exit Sub
        If m_HotTrack Then m_Hot = True
        Invalidate()
    End Sub

    Private Sub Tab_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
        MouseOverCloseButton = False
        m_Hot = False
        Invalidate()
    End Sub

    Private Sub Tab_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        Static State As Boolean = False
        If m_CloseButtonVisible Then
            ' verify if the mouse is over the close button
            Dim x As Integer = Me.Width - PadRight - m_CloseButtonSize.Width - 2
            Dim y As Integer = Me.Height / 2 - m_CloseButtonSize.Height / 2
            MouseOverCloseButton = e.X >= x And e.X <= x + m_CloseButtonSize.Width - 1 And e.Y >= y And e.Y <= y + m_CloseButtonSize.Height - 1
            If State <> MouseOverCloseButton And m_CloseButtonVisible Then
                State = MouseOverCloseButton
                Dim r As New Region(New Rectangle(x, y, m_CloseButtonSize.Width, m_CloseButtonSize.Height))
                Me.Invalidate(r)
                r.Dispose()
                r = Nothing
            End If
        End If
        If Me.RectangleToScreen(Me.ClientRectangle).Contains(Me.PointToScreen(New Point(e.X, e.Y))) Then
            Cursor = Cursors.Default
        Else ' the mouse is outside the tab (it happens only when the mouse was pressed on the tab and moved away while pressed)
            RaiseEvent Draging(Me, e)
            Cursor = Cursors.No
        End If
    End Sub

    ' Draws the tab text (the form text)
    Private Sub DrawText(ByVal g As Graphics)
        Dim f As Font = New Font(Font, IIf(m_Selected And m_FontBoldOnSelect, FontStyle.Bold, FontStyle.Regular))
        Dim b As Brush = New SolidBrush(IIf(m_Selected Or m_Hot, ForeColor, m_ForeColorDisabled))
        Dim bounds As RectangleF = New RectangleF(PadLeft + IIf(m_Form.Icon Is Nothing, 0, m_IconSize.Width) + 2, 1, Width - PadLeft - IIf(m_Form.Icon Is Nothing, 0, m_IconSize.Height) - 5 - IIf(m_CloseButtonVisible, m_CloseButtonSize.Width, 0) - PadRight, Me.DisplayRectangle.Height)
        Dim MyFormat As StringFormat = New StringFormat
        MyFormat.FormatFlags = StringFormatFlags.NoWrap
        MyFormat.LineAlignment = StringAlignment.Center
        MyFormat.Trimming = StringTrimming.EllipsisCharacter
        g.DrawString(m_Form.Text, f, b, bounds, MyFormat)
        MyFormat.Dispose()
        b.Dispose()
        f.Dispose()
        MyFormat = Nothing
        b = Nothing
        f = Nothing
    End Sub

    ' Draws the tab icon if exists (the form icon)
    Private Sub DrawIcon(ByVal g As Graphics)
        Try
            If m_Form.Icon Is Nothing Then Exit Sub
            Dim r As Rectangle = New Rectangle(PadLeft, (Me.Height / 2 - m_IconSize.Height / 2), m_IconSize.Width, m_IconSize.Height)
            Dim i As Icon = New Icon(m_Form.Icon, m_IconSize)
            g.DrawIcon(i, r)
            DestroyIcon(i.Handle)
            i.Dispose()
            i = Nothing
        Catch ex As Exception
        End Try
    End Sub

    <System.Runtime.InteropServices.DllImportAttribute("user32.dll")> _
    Private Shared Function DestroyIcon(ByVal handle As IntPtr) As Boolean
    End Function

⌨️ 快捷键说明

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