Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move on Mouse click 1

Status
Not open for further replies.
Apr 27, 2006
126
GB
Hi, moving a picture box around the screen following a mouse click (i know its only moving left/right at the moment, but thats not my concern... yet! heheh). This works fine and the image moves to where the mouse clicked. BUT, if i click again, or several times, while it is moving, it causes all hell to break loose and the image to start trying to perform all actions, previous and current. How can i put a check in to see if it is already processing a mousedown action and over=ride the current?

Code:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

startx = frmmapscreen.imgchar.Left
starty = frmmapscreen.imgchar.Top

If X > startx Then
    stepx = 5
Else
    stepx = -5
End If
If Y > starty Then
    stepy = 5
Else
    steyp = -5
End If
For movex = startx To X Step stepx
    PauseTime = 0.05    ' Set duration.
    Start = Timer    ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
    frmmapscreen.imgchar.Left = movex
Next movex

End Sub


Thanks in advance.  I know my questions have been a bit random lately :)

________
clueless
 
A starting point:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
[!]Static myFlag As Boolean
If myFlag Then Exit Sub
myFlag = True[/!]
startx = frmmapscreen.imgchar.Left
starty = frmmapscreen.imgchar.Top
...
Next movex
[!]myFlag = False[/!]
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
that works great, no more jumping around, although i was looking for the new click to assume control over the previous click. Regardless, this actually works out better so I thank you for that nugget of info PHV, *click*

________
clueless
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top