CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2008
    Location
    India, Bangalore
    Posts
    157

    Arrow How to make the slider to work frm the point where it got stopped?

    Hi All,

    I have 1 slider, 1 command btn by name Play, and another 1 command btn by name stop and 1 image viewer(in which the images are shown) and i have 1 timer in which i have writtn the code.

    When i run the project and click on Play btn(its a command btn) then slider wil star playing. When i click the stop btn then the slider wil get stopped. NOW MY Problem is when i stop the running of slider in the middle(example i wil stop it at 30th image then when i again click on the Play btn it should play from the 3oth image only) HOW to do this ????

    Plese somebody help me

    Thanks in Advance
    Seema.....

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to make the slider to work frm the point where it got stopped?

    Store the location when you hit the STOP button. Just save the last image shown. (You can use a STATIC variable)

    Code:
    Static ImgCtr as Integer
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: please help its urgent....

    [ Merged from Duplicate Thread ]

    Simple Enough.
    You declare a variable called Playing as a boolean in the form
    This is set to true in cmdPlay
    And to False in cmdStop
    In the timer, if playing is true, add 1 to slider.value, and displey the slider.value th image.
    Last edited by WizBang; January 8th, 2009 at 08:12 AM.
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: please help its urgent....

    I think the problem lies elsewhere.
    You have to keep track of the last image displayed, best in a Private variable in the playing form, which is visible by all code in the form.
    Private LastImage As Integer
    might serve as a counter, which image was last.

    Nevertheless the idea of having a boolean which is true when playing helps also a lot:
    Private Playing as Boolean
    - When pressing the start button you go Playing = True and start playing at image number LastImage
    - When pressing stop you go:
    If Playing then Playing = False Else LastImage = 0
    So: when pressing stop the first time, playing is stopped, but LastImage keeps its number.
    Pressing stop again will reset LastImage, so next time you start playing from the beginning.

  5. #5
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: please help its urgent....

    I honestly can't see the point in having a LastImage variable, when all slider controls have a .value variable, and the slider represents which image you are on. Perhaps I mis-understand what the project is for, but that seems in easiest solution...
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  6. #6
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: How to make the slider to work frm the point where it got stopped?

    Dpnt doublepost !!
    Its against Forum rules.
    This is the same
    http://www.codeguru.com/forum/showthread.php?t=468353
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  7. #7
    Join Date
    Dec 2001
    Posts
    6,332

    Re: How to make the slider to work frm the point where it got stopped?

    Another consideration, is if the user is allowed to move the slider position. Then, if the user stops playback, moves the slider, then starts playback again, shouldn't it start at the point determined by the slider?

    If so, then perhaps the timer should advance the slider only, and the slider events could then advance the image. In this way, when the user moves the slider, this will also change the image accordingly. However, if there are more images than there are possible slider values, you'll need to account for that.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  8. #8
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: please help its urgent....

    Quote Originally Posted by javajawa View Post
    I honestly can't see the point in having a LastImage variable, when all slider controls have a .value variable, and the slider represents which image you are on. Perhaps I mis-understand what the project is for, but that seems in easiest solution...
    Sure. You are right here. It would only be matter of programming philosophy. You don't need the LastImage variable, but you can treat the Slider.value property in exactly the same way as I described.

    In a way, continuing to play where it stopped last is somehow inherent in the slider control. Stopping to play means disabling the timer, and so the slider would stop where it is. Reenabling the timer would automatically resume playing where it stopped last.

    For more help you should show us some code.

  9. #9
    Join Date
    Jun 2008
    Location
    India, Bangalore
    Posts
    157

    Arrow Re: How to make the slider to work frm the point where it got stopped?

    Its working fine.

    dim Playing as boolean

    In Play button i added
    Playing=True

    In Stop button i added
    Playing=False

    Thanks for all of u, for your help.
    With regards
    Seema

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

Featured