Application.DoEvents() 的问题 [英] Issue with Application.DoEvents()
本文介绍了Application.DoEvents() 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的代码中使用了 Application.DoEvents()
以便我可以通过按下按钮退出循环,我遇到了一个问题,我必须先点击屏幕才能按下这个退出按钮,因此需要点击两次.每次我玩游戏时都会发生这种情况,然后尝试停止程序而不关闭它.我该如何解决这个问题?
I have used Application.DoEvents()
in my code so that I can exit a loop with a button press, I am having an issue where I have to click on the screen before I can press this exit button, thus needing two clicks. This happens every time I play then try to stop the program, without closing it. How would I fix this?
Do While StopProgram = False
Application.DoEvents()
RadianAngle = Angle * PlaceHolder
Me.Refresh()
If DirectionPositive = False Then
Angle += 1
If Angle = 51 Then
Angle = 49
DirectionPositive = True
End If
ElseIf DirectionPositive = True Then
Angle -= 1
If Angle = -51 Then
Angle = -49
DirectionPositive = False
End If
End If
Loop
<小时>
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
StopProgram = False
RunningProgram()
End Sub
<小时>
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
StopProgram = True
End Sub
推荐答案
一种解决方法:如果您使用 MouseDown 而不是 Click 事件,它会正常工作.
One workaround: It will work OK if you use MouseDown instead of Click events.
这篇关于Application.DoEvents() 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文