Results 1 to 10 of 10

Thread: [RESOLVED] about delay a procedure not a program

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,966

    Resolved [RESOLVED] about delay a procedure not a program

    i have these code:
    Code:
    If blnEnter = False Then
            'wait some milliseconds, but the rest of program must continue
            RaiseEvent MouseHover(mbMouseButton, skShift, MousePos.x, MousePos.y)
        End If
    before raiseevent, i must put a delay with same milliseconds, but these delay can't pause the project only these procedure.
    i try use the timer but doesn't work, because the intervale was ignored.
    can anyone help me?
    can i start the timer control interval from begin?
    thanks
    Last edited by joaquim; Jul 13th, 2008 at 05:50 PM.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: about delay a procedure not a program

    I guess you can use threading?
    Wait.Sorry in what language?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: about delay a procedure not a program

    For (single threaded) VB6 apps I think all you can really do is add DoEvents to your loops so the program doesn't appear frozen and still responds, so FWIW I'm not so sure this would help or not....

    Code:
    Option Explicit
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    
    '.........
    If blnEnter = False Then
       'Delay raise event 100 milliseconds...
      Call Delayed_Hover(100, mbMouseButton, skShift, MousePos.X, MousePos.Y)
    End If
    '......
    
    Private Sub Delayed_Hover(mSecs As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
       
        Dim start As Long
        Dim ending As Long
        
        start = GetTickCount
        Do
            DoEvents
            ending = GetTickCount
            If (ending - start) >= mSecs Then Exit Do
        Loop
        
        RaiseEvent MouseHover(Button, Shift, X, Y)
    End Sub

  4. #4

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,966

    Re: about delay a procedure not a program

    thanks but i continue with 1 problem.
    is like the timer not always do the intervale... just see it...
    thanks
    Last edited by joaquim; Jul 24th, 2008 at 07:59 PM.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,966

    Re: about delay a procedure not a program

    Quote Originally Posted by sapator
    I guess you can use threading?
    Wait.Sorry in what language?
    visual basic 6
    VB6 2D Sprite control

    To live is difficult, but we do it.

  6. #6
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: about delay a procedure not a program

    Quote Originally Posted by joaquim
    visual basic 6
    If a timer doesn't fire at it's set interval then other running code is probably taking longer to complete then the timer interval is set for. You might want to run a code profiler to see what sections of your code are taking the longest and make some adjustments. Or maybe look into VB6 multi-threading, there's some in the VB6 & earlier code bank.

  7. #7

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,966

    Re: about delay a procedure not a program

    Quote Originally Posted by Edgemeal
    If a timer doesn't fire at it's set interval then other running code is probably taking longer to complete then the timer interval is set for. You might want to run a code profiler to see what sections of your code are taking the longest and make some adjustments. Or maybe look into VB6 multi-threading, there's some in the VB6 & earlier code bank.
    (did you see my groupproject?)
    sometimes the code is call in some milliseconds(but not the real) and in others is call in less than that milliseconds.
    "Or maybe look into VB6 multi-threading, there's some in the VB6 & earlier code bank" where is it?
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  8. #8

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,966

    Re: about delay a procedure not a program

    ok i finaly resolve...
    i use(again) 1 timer...
    the MousePos.x and MousePos.y is the actual position
    the lngOldMouseX and lngOldMouseY are the last position saved.
    Code:
    If MousePos.x = lngOldMouseX And MousePos.y = lngOldMouseY And blnEnter = False Then
            RaiseEvent MouseHover(mbMouseButton, skShift, MousePos.x, MousePos.y)
        Else
            lngOldMouseX = MousePos.x
            lngOldMouseY = MousePos.y
        End If
    sims that the timer need more time that is need... maybe is about otherthing not finished, like you said.
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  9. #9
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: [RESOLVED] about delay a procedure not a program

    Ya I looked at the code and ran it but have no clue what its supposed to do or could I really follow the flow of the code.

    Glad you resolved it!

  10. #10

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,966

    Re: [RESOLVED] about delay a procedure not a program

    Quote Originally Posted by Edgemeal
    Ya I looked at the code and ran it but have no clue what its supposed to do or could I really follow the flow of the code.

    Glad you resolved it!
    when you pass hover the GifAnimator image you can see the mouseevents activate... but when you stop the mouse in image, with some milliseconds, the mouseHover must activate...
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

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