Video Style Track Bar - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Video Style Track Bar

seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
I have a solution that impliments the Trackbar control. I am grabbing 10,000 - 30,000 records from a database and supplying the Trackbar with a minimum value of 0 and a maximum of my last record. I then use the trackbar to navigate through the data....

I am hoping to implement more of a video style trackbar, like Media player's. I don't like the hash marks that get placed at the bottom of the track bar and etc. and now that I have developed the major portion of the core code I am really focusing in on user interface design.

Does anyone know of anything like what I am looking for? If I could just create a new trackbar implementing the old trackbar, if you told me what paint functions to overload that would work too.

Comments

  • HackmanCHackmanC Posts: 441Member
    Me.TrackBar1.TickStyle = System.Windows.Forms.TickStyle.None

    I believe there is no way to Override the OnPaint function on the TrackBar Control, and if you can, you should paint the whole control, the thumb you see is not a Window (hWnd from Api), at least that said Spy++ 7. Its a drawing. I give you the basic functionality, If you want to make your own Control:

    [code]
    Public Class TrackBarC
    Inherits System.Windows.Forms.Control

    Private myIcon As System.Drawing.Icon
    Private myX As Integer = 0 ' Here you have the position, from 0 to width - 32
    ' Have to write a translator that converts that to 100's or your values.
    Private myY As Integer = 0

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    MyBase.OnPaint(e)
    e.Graphics.DrawIcon(myIcon, myX, 16)
    End Sub

    Public Sub New()
    MyBase.New()
    myIcon = New System.Drawing.Icon("C:Archivos de programaMicrosoft Visual Studio .NETCommon7GraphicsiconsarrowsPOINT03.ICO")
    'In english should be :
    'C:Program FilesMicrosoft Visual Studio .NETCommon7GraphicsiconsarrowsPOINT03.ICO
    'Should be load from a resource anyway !!!
    Me.BackColor = System.Drawing.Color.DarkGray
    End Sub

    Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
    If e.Button = MouseButtons.Left Then
    myX = e.X - 16 ' The 16 value has to be the half the Icon Size (32x32)
    myY = e.Y - 16
    REM If myX <= 0 Then myX = 0 ' Special when out of Bounds
    REM If myX >= Me.Width - 32 Then myX = Me.Width - 32 ' Here too.
    Invalidate()
    Update()
    End If
    End Sub

    End Class
    [/code]

    And the form to test:

    [code]
    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents TrackBarC As WindowsApplication.TrackBarC
    Private Sub InitializeComponent()
    Me.TrackBarC = New WindowsApplication.TrackBarC()
    Me.SuspendLayout()
    '
    'TrackBarC
    '
    Me.TrackBarC.BackColor = System.Drawing.Color.DarkGray
    Me.TrackBarC.Location = New System.Drawing.Point(232, 56)
    Me.TrackBarC.Name = "TrackBarC"
    Me.TrackBarC.Size = New System.Drawing.Size(184, 104)
    Me.TrackBarC.TabIndex = 0
    Me.TrackBarC.Text = "TrackBarC"
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(512, 266)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TrackBarC})
    Me.Name = "Form1"
    Me.Text = "Form1"
    Me.ResumeLayout(False)

    End Sub

    #End Region

    End Class
    [/code]

    Note:
    [red]I belive this is a bad choice, when you have 10,000 records, the user never navigate between them. You need to focus in a impressive search implementation.[/red]

    ----
    : I have a solution that impliments the Trackbar control. I am grabbing 10,000 - 30,000 records from a database and supplying the Trackbar with a minimum value of 0 and a maximum of my last record. I then use the trackbar to navigate through the data....
    :
    : I am hoping to implement more of a video style trackbar, like Media player's. I don't like the hash marks that get placed at the bottom of the track bar and etc. and now that I have developed the major portion of the core code I am really focusing in on user interface design.
    :
    : Does anyone know of anything like what I am looking for? If I could just create a new trackbar implementing the old trackbar, if you told me what paint functions to overload that would work too.
    :

    [red]Good luck![/red]
    [blue]Hackman[/blue]

  • fwd079fwd079 Posts: 1Member
    Well I don't know if he thanked you or not, but you sure did help me.

    Cheers Hackman :)
  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    Haha, I didn't put a thanks up, good call.

    I ended up writing a custom user control to handle this project.

    Thanks for the help (from almost 2 years ago)
Sign In or Register to comment.