|
-
Feb 15th, 2010, 09:39 AM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6] - key event vs message box
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?
Last edited by joaquim; Feb 15th, 2010 at 09:48 AM.
-
Feb 15th, 2010, 09:48 AM
#2
Re: [VB6] - key vs message box
You mean this...??? 
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
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 15th, 2010, 09:50 AM
#3
Thread Starter
PowerPoster
Re: [VB6] - key vs message box
 Originally Posted by akhileshbc
You mean this...???
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
not in these way. the message box is called by another sub. is why i can't resolve it.
(if you want, i PM you with my project(has 1 ocx file, my Sprite control ))
-
Feb 15th, 2010, 10:00 AM
#4
Re: [VB6] - key event vs message box
Can you post that sub part...???
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 15th, 2010, 10:07 AM
#5
Thread Starter
PowerPoster
Re: [VB6] - key event vs message box
 Originally Posted by akhileshbc
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
-
Feb 15th, 2010, 10:11 AM
#6
Re: [VB6] - key event vs message box
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... ) ...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 15th, 2010, 10:20 AM
#7
Thread Starter
PowerPoster
Re: [VB6] - key event vs message box
 Originally Posted by akhileshbc
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... ) ... 
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:
Code:
If Points = lngDiamonds Then
KeyCode = 0
Exit Sub
End If
anotherthing my keydown event(in my control) has 1ms in interval of the timer
Last edited by joaquim; Feb 15th, 2010 at 10:25 AM.
-
Feb 15th, 2010, 10:54 AM
#8
Re: [VB6] - key event vs message box
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?
-
Feb 15th, 2010, 10:59 AM
#9
Thread Starter
PowerPoster
Re: [VB6] - key event vs message box
 Originally Posted by LaVolpe
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
-
Feb 15th, 2010, 11:04 AM
#10
Re: [VB6] - key event vs message box
We shouldn't need to view a complex ocx. What do you mean exactly by the following statement:
anotherthing my keydown event(in my control) has 1ms in interval of the timer
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.
-
Feb 15th, 2010, 11:24 AM
#11
Thread Starter
PowerPoster
Re: [VB6] - key event vs message box
 Originally Posted by LaVolpe
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.
finaly i resolve the problem... and yes, i give up from the messagebox and i build 1 form for work like messagebox. and resolve my problem
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|