Page 2 of 2 FirstFirst 12
Results 41 to 54 of 54

Thread: Clicking a progress bar and making the value the mouse's position(resolved)

  1. #41
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Clicking a progress bar and making the value the mouse's position

    Quote Originally Posted by paralinx
    can someone come up with a way to do this without the max being only 100??

    As I mentioned Set the .Max = SongLength
    That way the PB 'ticks' are representative of the song play postion....
    You would set the .Max at song load, and update the .Value based on the Song position.

    Does that make sense? Or, am I missing the obvious?

  2. #42
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Clicking a progress bar and making the value the mouse's position

    Wouldn't it be so much easier to ditch the progressbar and use a picturebox instead? Simply set the ScaleWidth property to the length of the song and to update the progress in it simply do this:
    VB Code:
    1. Public Sub ProgressValue(pic As PictureBox, nValue As Long)
    2.     pic.Line (nValue, 0) - (pic.ScaleWidth, pic.ScaleHeight), pic.BackColor, BF
    3.     pic.Line (0, 0)-(nValue, pic.ScaleHeight), vbBlue, BF
    4. End Sub
    The AutoRedraw property should be set to True.... Now in the MouseDown event use the X value directly to change the position in the current song and to update the progress in the picturebox.

  3. #43
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Clicking a progress bar and making the value the mouse's position

    I was gonna post about ScaleMode until I read JA's post. paralinx, you probably changed the ScaleMode property of your form, which is why it works with new projects.

  4. #44
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Clicking a progress bar and making the value the mouse's position

    Quote Originally Posted by paralinx
    do you know a way where I can change the computer's volume control that is found in the bottom right hand corner?
    You shouldn't alter that unless you really have to. Whatever method you're using to play audio, that should have a way of controlling its own volume.

  5. #45

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Clicking a progress bar and making the value the mouse's position

    I'd need a way to update the picture box during the song like the progress bar then. And I have no idea how.

  6. #46
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Clicking a progress bar and making the value the mouse's position

    You update the ProgressBar now by simply setting the Value property right? Well instead of setting the Value property call the ProgressValue Sub I showed above.

  7. #47
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Clicking a progress bar and making the value the mouse's position

    Quote Originally Posted by paralinx
    I'd need a way to update the picture box during the song like the progress bar then. And I have no idea how.
    As your no doubt aware you will need to be constantly cycling this app so that you can update the statusbar/picturebox, display the current song time, maybe time remaining. To do that you could use a Timer, a Loop etc. I think
    you mentioned
    that you are using a Timer - is that right?

    To put it simply, you will need something like:

    VB Code:
    1. 'A.
    2. Private Sub Timer1_Timer()
    3.         'Main code executes here (updates labels, progressbars etc)
    4. End Sub
    5.  
    6. 'OR
    7.  
    8. 'B.
    9.     Do Until Stop
    10.  
    11.         'Main code executes here (updates labels, progressbars etc)
    12.  
    13.     Loop

    Therefore, can you post the code that you have that performs the pseudo function above

  8. #48

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Clicking a progress bar and making the value the mouse's position

    Joacim, I am working with your code, and it will only update the picturebox once. Am i doing something wrong?

    VB Code:
    1. Private Sub tmrTimer_Timer()
    2.      Dim nReturnCode As Long
    3.      Dim dblPosition As Double
    4.          On Local Error GoTo ErrLine
    5.             Call ProgressValue(Pic, m_objMediaPosition.CurrentPosition)
    6. End Sub
    7.  
    8. Public Sub ProgressValue(Pic As PictureBox, nValue As Long)
    9.     Pic.Line (nValue, 0)-(Pic.ScaleWidth, Pic.ScaleHeight), Pic.BackColor, BF
    10.     Pic.Line (0, 0)-(nValue, Pic.ScaleHeight), vbBlue, BF
    11. End Sub

  9. #49
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Clicking a progress bar and making the value the mouse's position

    Have you set the ScaleWidth of the picturebox to the length of the song? You might need to also set the ScaleMode property to vbUser (this can be done during design time). The ScaleWidth will then act as the Max property.

  10. #50
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Clicking a progress bar and making the value the mouse's position

    Whats wrong with the slider from the microsoft common controls? Or even a scroll bar?

  11. #51

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Clicking a progress bar and making the value the mouse's position

    Quote Originally Posted by Joacim Andersson
    Have you set the ScaleWidth of the picturebox to the length of the song? You might need to also set the ScaleMode property to vbUser (this can be done during design time). The ScaleWidth will then act as the Max property.
    Ok I got it working now. Would you know the code for when I click anyone on the picture box that i could set the position of the blue line to where the mouse click was?

  12. #52
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Clicking a progress bar and making the value the mouse's position

    In the MouseDown or MouseUp event use the X argument to determent what value you should set the CurrentPosition of the song to. The Timer event will then update the picture box.

  13. #53

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: Clicking a progress bar and making the value the mouse's position

    Holy cow! It's a miracle I got it to work finally!

    Thanks every so much for all you're help!

    Here's the final code that I used

    VB Code:
    1. m_objMediaPosition.CurrentPosition = (X * m_objMediaPosition.Duration) / Pic.ScaleWidth

  14. #54
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Clicking a progress bar and making the value the mouse's position(resolved)

    Well, I'm glad you got it working However if you would have set the ScaleWidth of the picture box to the duration of the song whenever a new song is selected you shouldn't need to do the above calculation.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width