Results 1 to 8 of 8

Thread: Pause

  1. #1
    champgary
    Guest

    Pause

    Hi there,
    Does anybody know how code the pause button
    I have no of gifs, which play one by one, i want to pause any of it between
    I am using gif89.dll for that, but pause method is not available with this,
    Any idea,
    Please...
    Gary

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Try the Sleep API
    VB Code:
    1. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    2.  
    3. Private Sub cmdPause_Click()
    4. Sleep 5000
    5. 'In this case, the 5000 milliseconds puts the application to bed for 5 seconds.
    6. End Sub

  3. #3
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    Does this API affect all processes or only the app that uses it?

  4. #4
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    Does this API affect all processes or only the app that uses it?

  5. #5
    champgary
    Guest
    Originally posted by Hack
    Try the Sleep API
    VB Code:
    1. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    2.  
    3. Private Sub cmdPause_Click()
    4. Sleep 5000
    5. 'In this case, the 5000 milliseconds puts the application to bed for 5 seconds.
    6. End Sub
    But this will pause my other processes also,
    the other processes should keep going,
    and another problem is that ..after sleep complete, the gif will automatically play.....
    but doesn't go like this....I want it this way
    When user click on pause, the image will pause till user click on play button, like mp3 player

    Any other idea

    Gary

  6. #6
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Add this to a Module

    VB Code:
    1. Public Declare Function GetTickCount Lib "kernel32" () As Long
    2.  
    3.  
    4. Sub Pause(Length As Long)
    5. Dim OldTime As Long
    6. OldTime = GetTickCount
    7. Do
    8. DoEvents
    9. If GetTickCount >= OldTime + Length Then Exit Do
    10. Loop
    11. End Sub


    1second = Pause(1000)


    I wrote that pause sub because it can pause from 1,000th of a second to several days. Most pause subs use the built in "Timer" function.. these are ok but don't allow as wide a variaty of pause times. And the Sleep API sucks becasue it puts your whole program to sleep.

    So gettickcount is the only way to go.
    Last edited by Arc; Jun 25th, 2002 at 01:41 AM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  7. #7
    Hyperactive Member
    Join Date
    May 2002
    Location
    Chicago
    Posts
    271
    Try something like this:
    Code:
    Private Sub Form_Load()
      Command1.Caption = "Pause"
    End Sub
    
    Private Sub Command1_Click()
      'toggle command caption
      If Command1.Caption = "Pause" Then 'user wants to pause
        Command1.Caption = "Resume"
        'even though the button shows resume the app is paused
      Else 'user wants to resume
        Command1.Caption = "Pause"
      End If
    End Sub
    
      'then place this in the loop that shows your pictures
      Do While Command1.Caption <> "Pause"
      'for faster code use:
      'Do While Len(Command1)=5
        DoEvents
      Loop
    Sometimes what you're looking for is exactly where you left it.

  8. #8
    champgary
    Guest
    Originally posted by JohnVB6
    Try something like this:
    Code:
    Private Sub Form_Load()
      Command1.Caption = "Pause"
    End Sub
    
    Private Sub Command1_Click()
      'toggle command caption
      If Command1.Caption = "Pause" Then 'user wants to pause
        Command1.Caption = "Resume"
        'even though the button shows resume the app is paused
      Else 'user wants to resume
        Command1.Caption = "Pause"
      End If
    End Sub
    
      'then place this in the loop that shows your pictures
      Do While Command1.Caption <> "Pause"
      'for faster code use:
      'Do While Len(Command1)=5
        DoEvents
      Loop
    Aha..
    thanx.

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