Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

TabControl navigation button hide

Hey everyone,

i have this tabcontrol from FireFox theme and i made some changes like resizing tabpages to fit width of tabcontrol as shown on image below but i cannot manage to disable those navigation buttons. Is there any way to hide/disable navigation buttons?

[Image: 2zBxFmr] link to image


PHP Code

<?php 
Class FirefoxSubTabControlSecond
    Inherits TabControl

#Region " Private "
    
Private G As Graphics
    
Private TabRect As Rectangle
#End Region

#Region " Control "

    
Public Overrides ReadOnly Property DisplayRectangle As System.Drawing.Rectangle
        Get
            Dim rc 
As Rectangle = MyBase.DisplayRectangle
            rc
.Offset(-3, -1)
            
rc.Width += 6
            rc
.Height += 4
            
Return rc
        End Get
    End Property

    Sub 
New()
        
DoubleBuffered = True
        Alignment 
= TabAlignment.Top
        Font 
= New Font("Segoe UI", 10)
    
End Sub

    
Protected Overrides Sub OnCreateControl()
        
MyBase.OnCreateControl()
        
SetStyle(ControlStyles.UserPaint, True)

        
Dim w As Double = Width
        Dim items 
As Integer = TabPages.Count

        ItemSize 
= New Size((w / items), 40)

        
'ItemSize = New Size(150, 40)
        SizeMode = TabSizeMode.Fixed
    End Sub

    Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
        MyBase.OnControlAdded(e)
        Try
            For i As Integer = 0 To TabPages.Count - 1
                TabPages(i).BackColor = Color.FromArgb(255, 255, 255)
                TabPages(i).ForeColor = Color.FromArgb(127, 150, 158)
                TabPages(i).Font = New Font("Segoe UI", 10)
            Next
        Catch
        End Try
    End Sub

    Protected Overrides Sub OnPaint(e As PaintEventArgs)

        G = e.Graphics
        G.SmoothingMode = SmoothingMode.HighQuality
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit

        MyBase.OnPaint(e)

        G.Clear(Color.White)

        For i As Integer = 0 To TabPages.Count - 1

            TabRect = GetTabRect(i)

            Dim FontColor As New Color

            Dim titleX As Integer = (GetTabRect(i).Location.X + GetTabRect(i).Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2)
            Dim titleY As Integer = (GetTabRect(i).Location.Y + GetTabRect(i).Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2)


            If SelectedIndex = i Then

                Using B As New SolidBrush(Color.FromArgb(253, 253, 253))
                    G.FillRectangle(B, New Rectangle(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2, GetTabRect(i).Width, GetTabRect(i).Height + 1))
                End Using

                FontColor = Color.FromArgb(77, 96, 101)

            Else

                FontColor = Color.FromArgb(127, 150, 158)

                End If

                Using p As New Pen(Color.FromArgb(235, 235, 235), 1)
                    G.DrawLine(p, New Point(TabRect.X + TabRect.Width - 3, TabRect.Y + TabRect.Height), New Point(TabRect.X + TabRect.Width - 3, TabRect.Y - 12))
                End Using

                G.DrawString(TabPages(i).Text, Font, New SolidBrush(FontColor), New Point(titleX, titleY))

        Next

        Using P As New Pen(Color.FromArgb(235, 235, 235), 1)
            '
TopMost
            G
.DrawLine(P, New Point(0, ItemSize.Height + 2), New Point(Width, ItemSize.Height + 2))
            
'Top
            G.DrawLine(P, New Point(0, 0), New Point(Width, 0))
            '
Left
            G
.DrawLine(P, New Point(0, 0), New Point(0, Height))
            
'Bottom
            G.DrawLine(P, New Point(0, Height - 1), New Point(Width, Height - 1))
            '
Right
            G
.DrawLine(P, New Point(Width - 1, 0), New Point(Width - 1, Height))
        
End Using

    End Sub

#End Region

End Class 
You can try this:
https://stackoverflow.com/a/5489739

Or possibly this:
https://msdn.microsoft.com/en-us/library...s.85).aspx
You can create a controller for that tab control.
[Image: narwinsig.gif]
Thanks.

@Orka I tried that and it didn't help me.

@Ninja The first link is great if you want hide scrollbars on panels but doesn't work with this issue

@.cYRil. Too much work for me.

Thank you all for your help, but i figured out how to do with drawing tabpages in on paint event, in code where i divide width with tabpages count i put width - 5px and move right borders 5px on left so that last tabpages never goes offset and those navigation buttons never be summoned.

It's not good solution but it works.

Image
(Jan 25, 2018 06:54 AM)edin_ Wrote:  @Ninja The first link is great if you want hide scrollbars on panels but doesn't work with this issue

You can use the same method to filter the message that enables the navigation button on the TabControl I am pretty sure. You need to look on MSDN for the message though.

EDIT: Maybe this helps:
https://dotnetrix.co.uk/tabcontrol.htm#tip14

EDIT2: Here are the tabcontrol messages:
https://msdn.microsoft.com/en-us/library...s.85).aspx


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by SIM-3933056Apr 16, 2021 02:08 PM 29 1,214 Apr 16, 2021 02:08 PM
Last Post: centan
[.NET] by LeonieHackPetaBytes2Jan 23, 2019 05:10 PM 1 225 Jan 23, 2019 05:10 PM
Last Post: 0xDEAD10CC
[.NET] by sgamesOct 15, 2018 10:19 AM 5 343 Oct 15, 2018 10:19 AM
Last Post: sgames