Hi,
Could anyone give me some suggestion?
How can I detect the button is pressed continuously? Actually, I use Command1_MouseDown , but it is not succeed.
I would like to do the application continuously if the button is pressed. If the user release (mouse up), I will stop the application.
PrivateSub Command1_MouseUp(Button AsInteger, Shift AsInteger, X AsSingle, Y AsSingle)
bRunning = false
endsub
all this is nice and all, but won't really help much if your program is looping intencely and doesnt' pay attention to the events... so be sure to DoEvents
Can I ask you one more question? What the difference between MouseDown and Click ?
MouseDown is when you push the mouse button down... it's not a full click, just when you press the button...
Click is a full click... mouse down / mouse up in close succession over the same object / location...
typicly click would be used... just detects if the user has clicked something in a normal kind of way... however, i understood your specifications to say that the program would run continually until the button was released... so, mouse down fires where as click won't... then you can use mouse up later to break the loop
You know, after doing doEvents , our program should Exit Do .
Thank a lot.
zawpai
hello zawpai
I don't fully understand, and may have misunderstood your initial problem. You were having problems with the MouseDown event, which you were trying to use to cause your program to run continually until the button was released. I assumed that you meant that you had a section of code that you wanted to run repeatedly while the button was held down.
As such, i put it in a do while loop, with the clause that bRunning had to be true for the loop to continue... DoEvents prevents the program from taking full priority in the loop, causing the events that should be firing to fire vs waiting in the loop for whatever clause or justification that needs to be met to be met...
MouseDown is when you push the mouse button down... it's not a full click, just when you press the button...
Click is a full click... mouse down / mouse up in close succession over the same object / location...
Thank you for your good explanation. Now, I am clear about it.
(Toggle Plain Text)
private sub doLoopedStuff()
do while(bRunning=true)
'your code stuff
doEvents
loop
end sub
You know, after doing doEvents , our program should Exit Do .
Sorry for above case, I didn't mean you are wrong. You are right.
Because of my application, I just change the sequence.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.