Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9120733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:41:25+00:00 2026-06-17T05:41:25+00:00

I found many tutorials on youtube which tell us, how to use AxWindowsMediaPlayer and

  • 0

I found many tutorials on youtube which tell us, how to use AxWindowsMediaPlayer and basic stuff like creating your own volume control using TrackBar1 for Windows Media Player Component. But now I want to ask that how we can create our own movie duration control using trackbar or a seek slider in vb.net for Windows Media Player. I have searched a lot but question still remains a question. I hope that many great developers of vb.net on this site, should tell me logic behind it

THANKS IN ADVANCE

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:41:26+00:00Added an answer on June 17, 2026 at 5:41 am

    The trick is to subclass the TrackBar control and handle the OnPaintBackground and OnPaint events.
    Here’s an “extra-lite” version of a control I use on some of my own projects.

    This version is quite limited but it should help you get started…

    Imports System.Drawing.Drawing2D
    
    Public Class CoolTrackBar
        Inherits TrackBar
    
        Private thumbRect As Rectangle = New Rectangle(0, 0, 19, 19)
        Private isOverThumb As Boolean
        Private cachedValue As Integer
        Private rangeRect As Rectangle = Rectangle.Empty
    
        Private mGrooveSize As Integer = 6
        Private mGrooveBorderColor As Color = Color.Gray
        Private mGrooveColor As Color = Color.LightGray
    
        Private mSelStartColor As Color = Color.Blue
        Private mSelEndColor As Color = Color.Red
    
        Public Sub New()
            Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
            Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
            Me.SetStyle(ControlStyles.ResizeRedraw, True)
            Me.SetStyle(ControlStyles.UserPaint, True)
            Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
        End Sub
    
        Public Property GrooveSize As Integer
            Get
                Return mGrooveSize
            End Get
            Set(value As Integer)
                mGrooveSize = value
                Me.Invalidate()
            End Set
        End Property
    
        Public Property GrooveColor As Color
            Get
                Return mGrooveColor
            End Get
            Set(value As Color)
                mGrooveColor = value
                Me.Invalidate()
            End Set
        End Property
    
        Public Property GrooveBorderColor As Color
            Get
                Return mGrooveBorderColor
            End Get
            Set(value As Color)
                mGrooveBorderColor = value
                Me.Invalidate()
            End Set
        End Property
    
        Public Overloads Property TickStyle As TickStyle
            Get
                Return Windows.Forms.TickStyle.Both
            End Get
            Set(value As TickStyle)
                MyBase.TickStyle = Windows.Forms.TickStyle.Both
            End Set
        End Property
    
        Protected Overrides Sub OnPaintBackground(pevent As PaintEventArgs)
            Dim g As Graphics = pevent.Graphics
            Dim r As Rectangle = Me.DisplayRectangle
    
            Select Case MyBase.Orientation
                Case Orientation.Horizontal
                    rangeRect = New Rectangle(r.X + 14, r.Top, r.Width - 30, r.Height)
                Case Orientation.Vertical
                    rangeRect = New Rectangle(r.X + 5, r.Y + 14, r.Width, r.Height - 29)
            End Select
    
            MyBase.OnPaintBackground(pevent)
    
            DrawGroove(g)
        End Sub
    
        Protected Overrides Sub OnPaint(e As PaintEventArgs)
            Dim g As Graphics = e.Graphics
    
            DrawThumb(g)
        End Sub
    
        Private Sub DrawGroove(g As Graphics)
            Dim r1 As Rectangle
            Dim r2 As Rectangle
    
            Select Case Orientation
                Case Windows.Forms.Orientation.Horizontal
                    r1 = New Rectangle(rangeRect.X, rangeRect.Y + (rangeRect.Height - mGrooveSize) \ 2, rangeRect.Width, mGrooveSize)
                    r2 = New Rectangle(r1.X, r1.Y, r1.Width * ValueToPercentage(cachedValue), r1.Height)
                Case Windows.Forms.Orientation.Vertical
                    r1 = New Rectangle(rangeRect.X + (rangeRect.Width - mGrooveSize) / 2 - mGrooveSize \ 2, rangeRect.Y, mGrooveSize, rangeRect.Height)
                    r2 = New Rectangle(r1.X, r1.Y, r1.Width, r1.Height * ValueToPercentage(cachedValue))
            End Select
    
            Using b As New SolidBrush(mGrooveColor)
                g.FillRectangle(b, r1)
            End Using
    
            Using p As New Pen(mGrooveBorderColor)
                g.DrawRectangle(p, r1)
            End Using
    
            Using lgb As New LinearGradientBrush(r1.Location, New Point(r1.Right, r1.Bottom), mSelStartColor, mSelEndColor)
                g.FillRectangle(lgb, r2)
            End Using
        End Sub
    
        Private Sub DrawThumb(g As Graphics)
            Dim thumb As VisualStyles.VisualStyleElement = Nothing
    
            Select Case MyBase.Orientation
                Case Orientation.Horizontal
                    If MyBase.Enabled Then
                        If isOverThumb Then
                            thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbTop.Hot
                        Else
                            If MyBase.Focused Then
                                thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbTop.Focused
                            Else
                                thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbTop.Normal
                            End If
                        End If
                    Else
                        thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbTop.Disabled
                    End If
                Case Orientation.Vertical
                    If MyBase.Enabled Then
                        If isOverThumb Then
                            thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbRight.Hot
                        Else
                            If MyBase.Focused Then
                                thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbRight.Focused
                            Else
                                thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbRight.Normal
                            End If
                        End If
                    Else
                        thumb = VisualStyles.VisualStyleElement.TrackBar.ThumbRight.Disabled
                    End If
            End Select
    
            Dim valuePercentage As Single = ValueToPercentage(cachedValue)
            Dim vsr = New VisualStyles.VisualStyleRenderer(thumb)
            thumbRect.Size = vsr.GetPartSize(g, VisualStyles.ThemeSizeType.Draw)
    
            Dim pos As Integer
            Select Case MyBase.Orientation
                Case Orientation.Horizontal
                    pos = valuePercentage * rangeRect.Width
                    thumbRect.Location = New Point(pos + thumbRect.Width / 2 + 3, rangeRect.Y + thumbRect.Height / 2 + mGrooveSize / 4)
                Case Orientation.Vertical
                    pos = valuePercentage * rangeRect.Height
                    thumbRect.Location = New Point(rangeRect.X + thumbRect.Width / 2 + mGrooveSize / 4, pos + thumbRect.Height / 2 + 3)
            End Select
    
            vsr.DrawBackground(g, thumbRect)
        End Sub
    
        Private Function ValueToPercentage(value As Integer) As Single
            Dim w As Integer = MyBase.Maximum - MyBase.Minimum
            Dim min = MyBase.Minimum
            Dim max = MyBase.Maximum
    
            If MyBase.Orientation = Orientation.Horizontal Then
                Return (value - min) / (max - min)
            Else
                Return 1 - (value - min) / (max - min)
            End If
        End Function
    
        Private Sub CoolTrackBar_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
            If thumbRect.IntersectsWith(New Rectangle(e.Location, New Size(1, 1))) Then
                isOverThumb = True
                Me.Invalidate()
            ElseIf isOverThumb Then
                isOverThumb = False
                Me.Invalidate()
            End If
        End Sub
    
        Private Sub CoolTrackBar_ValueChanged(sender As Object, e As EventArgs) Handles Me.ValueChanged
            cachedValue = MyBase.Value
            Me.Invalidate()
        End Sub
    End Class
    

    To use it, simply create a WinForms project, then create a new Class, name it CoolTrackBar and paste the code above.
    You’ll need to compile the solution for the control to appear on your Toolbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to assembly language. I have found so many tutorials that
I found many pages of my maintenance website inherits a base page which overrides
I have found many core data with nsfetchedresultscontroller tutorials, but none of them are
I found many tutorials on how to deploy a SQLite Database together with an
Did some search online, found simple 'tutorials' to use named pipes. However when I
Although there are many tutorials out there, I've found it really difficult to implement
I've followed so many tutorials now and I can't get this basic, fundamental thing
Instead of installing User-Scripts I found many tutorials on the web to add it
I've been searching lots and found many tutorials for Javascript / jquery on click
I've been messing with Android for a couple of weeks, i found many tutorials

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.