when i use a message box, how can i ignore the key event?
because if i press 1 key and then the message box is activated. after the message box desapper, the key event continues active.
how can i avoid these problem?
Printable View
when i use a message box, how can i ignore the key event?
because if i press 1 key and then the message box is activated. after the message box desapper, the key event continues active.
how can i avoid these problem?
You mean this...??? :wave:
Code:Option Explicit
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print "Before"
MsgBox "Hello" '~~~> Display a message box
Debug.Print "After" '~~~> Works only after the Msgbox is closed (or OK button is pressed)
End Sub
Can you post that sub part...???
in colision event(i have a timer in control to test the move event and after the colision event):
Code:If sprPoints(ObjectIndex).Visible = True Then
sprPoints(ObjectIndex).Visible = False
lngPoints = lngPoints + 10
txtPoints.Text = "Points: " & Format(lngPoints, "0000")
Points = Points + 1
If Points = lngDiamonds Then
txtPoints.Text = "Congratulatious - Points: " & Format(lngPoints, "0000")
txtPoints.Width = 3900
If MsgBox("Did you want restart the game?", vbYesNo, "Restart the game...") = vbYes Then
Call RestartGame
Else
End
End If
End If
End If
Include the line Exit Sub after the msgbox. It will prevent the rest of the code from executing.(If that is not what you want, then please explain it... ) ... :wave:
i try use a boolean variable, but without sucess. i activate the varible before the message box for try cancel the keycode variable(in key event). but without sucess:(
and i try in these way too:
anotherthing my keydown event(in my control) has 1ms in interval of the timerCode:If Points = lngDiamonds Then
KeyCode = 0
Exit Sub
End If
If your timer using APIs to monitor the keyboard? If so, disable the timer before displaying the msgbox and re-enable if a new game is about to begin. The timers should probably be disabled after the game is over anyway, no?
hi LaVolte;)
by some reason i can't use my api timer control, but i remember(by you) that i can use the code instead the control;)
the variable, before msgbox that i can use is poinst compared by lngdiamonds, but still not working.
(can i send to you my project, by pm you(i have 1 ocx file)?)
thanks
We shouldn't need to view a complex ocx. What do you mean exactly by the following statement:
That is where I think the problem is. You shouldn't be monitoring the keyboard with timers/APIs while displaying message boxes or when the game terminates. Keep this in mind too. In IDE, MsgBoxes pause timers until the msgbox closes. When compiled, this is not true, the timers will not pause.Quote:
anotherthing my keydown event(in my control) has 1ms in interval of the timer