MsgBox pauses App at Design time but not run time 
Author Message
 MsgBox pauses App at Design time but not run time

I am making a game, and after some comments from various testers, they felt
they would like to pause the game during gameplay.  i though well thats
easy... but alas it is not!

I thought that a simle Msgbox vbokonly would do the trick so i put this code
in the keydown event.

    If KeyCode = 80 Or KeyCode = 19 Then
        MsgBox "Game Paused", vbOKOnly, "game Info"
    End If

that detects the pressing of the "p" key or the pause/break key and a
msgbox appears and the game is paused until ok is clicked. This works
perfectly at design time, but i was horrifie to discover that at runtime the
game still runs behind the msgbox and it does not stop.

Can someone tell me why this is? I need s pause function.

I thought about using the Sleep API, but i wouldn't know how to wake it
again because the program is asleep, not registering events.

Please Help.
Thanks

FatTony,
on VB6



Sat, 28 Feb 2004 14:10:41 GMT  
 MsgBox pauses App at Design time but not run time
On Tue, 11 Sep 2001 14:10:41 +0800, "Tony Johnson"

Hm ? Try adding vbapplicationmodal to the flags, maybe the constant
has been changed or somthing.
I normally implement the pause in the main loop with a sub doing a
loop with simply doevents and Form KeyPress checking for 'P' toggling
a boolean.

This is callled on 'P'
Private Sub DoPause()
        PopPause.Show ' show pause form.
        do while pauseFlag <> True 'pauseflag was set by keypress
                DoEvents
        loop
        PopPause.Hide
End Sub

Quote:
>I am making a game, and after some comments from various testers, they felt
>they would like to pause the game during gameplay.  i though well thats
>easy... but alas it is not!

>I thought that a simle Msgbox vbokonly would do the trick so i put this code
>in the keydown event.

>    If KeyCode = 80 Or KeyCode = 19 Then
>        MsgBox "Game Paused", vbOKOnly, "game Info"
>    End If

>that detects the pressing of the "p" key or the pause/break key and a
>msgbox appears and the game is paused until ok is clicked. This works
>perfectly at design time, but i was horrifie to discover that at runtime the
>game still runs behind the msgbox and it does not stop.

>Can someone tell me why this is? I need s pause function.

>I thought about using the Sleep API, but i wouldn't know how to wake it
>again because the program is asleep, not registering events.

>Please Help.
>Thanks

>FatTony,
>on VB6

Regards, Frank


Sat, 28 Feb 2004 15:15:14 GMT  
 MsgBox pauses App at Design time but not run time

Try something like that:

Dim t as long
If KeyCode = 80 Or KeyCode = 19 Then
  t = 0
  do while t = 0
    t = MsgBox("Game Paused", vbOKOnly, "game Info")
    doevents
  loop
End If

The program loop until the user click the OK button.

------
User of http://www.foorum.com/. The best tools for usenet searching.



Sat, 28 Feb 2004 16:40:56 GMT  
 MsgBox pauses App at Design time but not run time
Weird - normally the problem is that a MsgBox freezes the thread.

On Tue, 11 Sep 2001 14:10:41 +0800, "Tony Johnson"

Quote:

>I am making a game, and after some comments from various testers, they felt
>they would like to pause the game during gameplay.  i though well thats
>easy... but alas it is not!

>I thought that a simle Msgbox vbokonly would do the trick so i put this code
>in the keydown event.

>    If KeyCode = 80 Or KeyCode = 19 Then
>        MsgBox "Game Paused", vbOKOnly, "game Info"
>    End If

>that detects the pressing of the "p" key or the pause/break key and a
>msgbox appears and the game is paused until ok is clicked. This works
>perfectly at design time, but i was horrifie to discover that at runtime the
>game still runs behind the msgbox and it does not stop.

>Can someone tell me why this is? I need s pause function.

>I thought about using the Sleep API, but i wouldn't know how to wake it
>again because the program is asleep, not registering events.

>Please Help.
>Thanks

>FatTony,
>on VB6



Sat, 28 Feb 2004 20:18:56 GMT  
 MsgBox pauses App at Design time but not run time
How is your game running - are you using any timers?

J.


Quote:
> I am making a game, and after some comments from various testers, they
felt
> they would like to pause the game during gameplay.  i though well thats
> easy... but alas it is not!

> I thought that a simle Msgbox vbokonly would do the trick so i put this
code
> in the keydown event.

>     If KeyCode = 80 Or KeyCode = 19 Then
>         MsgBox "Game Paused", vbOKOnly, "game Info"
>     End If

> that detects the pressing of the "p" key or the pause/break key and a
> msgbox appears and the game is paused until ok is clicked. This works
> perfectly at design time, but i was horrifie to discover that at runtime
the
> game still runs behind the msgbox and it does not stop.

> Can someone tell me why this is? I need s pause function.

> I thought about using the Sleep API, but i wouldn't know how to wake it
> again because the program is asleep, not registering events.

> Please Help.
> Thanks

> FatTony,
> on VB6



Sat, 28 Feb 2004 20:49:49 GMT  
 MsgBox pauses App at Design time but not run time
Yes... lots of timers about 6 or so to control the movement of objects..


Quote:
> How is your game running - are you using any timers?

> J.



> > I am making a game, and after some comments from various testers, they
> felt
> > they would like to pause the game during gameplay.  i though well thats
> > easy... but alas it is not!

> > I thought that a simle Msgbox vbokonly would do the trick so i put this
> code
> > in the keydown event.

> >     If KeyCode = 80 Or KeyCode = 19 Then
> >         MsgBox "Game Paused", vbOKOnly, "game Info"
> >     End If

> > that detects the pressing of the "p" key or the pause/break key and a
> > msgbox appears and the game is paused until ok is clicked. This works
> > perfectly at design time, but i was horrifie to discover that at runtime
> the
> > game still runs behind the msgbox and it does not stop.

> > Can someone tell me why this is? I need s pause function.

> > I thought about using the Sleep API, but i wouldn't know how to wake it
> > again because the program is asleep, not registering events.

> > Please Help.
> > Thanks

> > FatTony,
> > on VB6



Mon, 01 Mar 2004 16:31:56 GMT  
 MsgBox pauses App at Design time but not run time
MsgBox or MessageBox ?

Has somebody re-scoped your MsgBox ?

On Thu, 13 Sep 2001 16:31:56 +0800, "Tony Johnson"

Quote:

>Yes... lots of timers about 6 or so to control the movement of objects..



>> How is your game running - are you using any timers?

>> J.



>> > I am making a game, and after some comments from various testers, they
>> felt
>> > they would like to pause the game during gameplay.  i though well thats
>> > easy... but alas it is not!

>> > I thought that a simle Msgbox vbokonly would do the trick so i put this
>> code
>> > in the keydown event.

>> >     If KeyCode = 80 Or KeyCode = 19 Then
>> >         MsgBox "Game Paused", vbOKOnly, "game Info"
>> >     End If

>> > that detects the pressing of the "p" key or the pause/break key and a
>> > msgbox appears and the game is paused until ok is clicked. This works
>> > perfectly at design time, but i was horrifie to discover that at runtime
>> the
>> > game still runs behind the msgbox and it does not stop.

>> > Can someone tell me why this is? I need s pause function.

>> > I thought about using the Sleep API, but i wouldn't know how to wake it
>> > again because the program is asleep, not registering events.

>> > Please Help.
>> > Thanks

>> > FatTony,
>> > on VB6



Mon, 01 Mar 2004 22:48:05 GMT  
 MsgBox pauses App at Design time but not run time
Excuse my ignornace if i am wrong... but what the hell are you talking
about?

is a MsgBox different from a MessageBox, and how can this help me if it is?

re-scopped?

im new to all this... are you speaking VB?

FatTony,


Quote:
> MsgBox or MessageBox ?

> Has somebody re-scoped your MsgBox ?

> On Thu, 13 Sep 2001 16:31:56 +0800, "Tony Johnson"

> >Yes... lots of timers about 6 or so to control the movement of objects..



> >> How is your game running - are you using any timers?

> >> J.



> >> > I am making a game, and after some comments from various testers,
they
> >> felt
> >> > they would like to pause the game during gameplay.  i though well
thats
> >> > easy... but alas it is not!

> >> > I thought that a simle Msgbox vbokonly would do the trick so i put
this
> >> code
> >> > in the keydown event.

> >> >     If KeyCode = 80 Or KeyCode = 19 Then
> >> >         MsgBox "Game Paused", vbOKOnly, "game Info"
> >> >     End If

> >> > that detects the pressing of the "p" key or the pause/break key and a
> >> > msgbox appears and the game is paused until ok is clicked. This works
> >> > perfectly at design time, but i was horrifie to discover that at
runtime
> >> the
> >> > game still runs behind the msgbox and it does not stop.

> >> > Can someone tell me why this is? I need s pause function.

> >> > I thought about using the Sleep API, but i wouldn't know how to wake
it
> >> > again because the program is asleep, not registering events.

> >> > Please Help.
> >> > Thanks

> >> > FatTony,
> >> > on VB6



Tue, 02 Mar 2004 01:01:28 GMT  
 MsgBox pauses App at Design time but not run time
On Fri, 14 Sep 2001 01:01:28 +0800, "Tony Johnson"

He means that the internal timer is stopped by the VB MsgBox but if
you were using the MessageBox API then it may not do so. I dunno, i've
never used the API from VB <shrug>

If you're still having problems, it may be time to explain the
workings of your code, or you may email me a copy of your project so i
can look at what's happening.

Quote:
>Excuse my ignornace if i am wrong... but what the hell are you talking
>about?

>is a MsgBox different from a MessageBox, and how can this help me if it is?

>re-scopped?

>im new to all this... are you speaking VB?

>FatTony,



>> MsgBox or MessageBox ?

>> Has somebody re-scoped your MsgBox ?

>> On Thu, 13 Sep 2001 16:31:56 +0800, "Tony Johnson"

>> >Yes... lots of timers about 6 or so to control the movement of objects..



>> >> How is your game running - are you using any timers?

>> >> J.



>> >> > I am making a game, and after some comments from various testers,
>they
>> >> felt
>> >> > they would like to pause the game during gameplay.  i though well
>thats
>> >> > easy... but alas it is not!

>> >> > I thought that a simle Msgbox vbokonly would do the trick so i put
>this
>> >> code
>> >> > in the keydown event.

>> >> >     If KeyCode = 80 Or KeyCode = 19 Then
>> >> >         MsgBox "Game Paused", vbOKOnly, "game Info"
>> >> >     End If

>> >> > that detects the pressing of the "p" key or the pause/break key and a
>> >> > msgbox appears and the game is paused until ok is clicked. This works
>> >> > perfectly at design time, but i was horrifie to discover that at
>runtime
>> >> the
>> >> > game still runs behind the msgbox and it does not stop.

>> >> > Can someone tell me why this is? I need s pause function.

>> >> > I thought about using the Sleep API, but i wouldn't know how to wake
>it
>> >> > again because the program is asleep, not registering events.

>> >> > Please Help.
>> >> > Thanks

>> >> > FatTony,
>> >> > on VB6

Regards, Frank


Tue, 02 Mar 2004 01:25:01 GMT  
 MsgBox pauses App at Design time but not run time
GIO - Gottit In One - thanks Frank - tomorrow I shall be sober, but
right now I need an interpreter .. funny that ... I wrote one once.

Someone has been tinkering with his MsgBox - and he has run out of
Occam's razors.



Quote:
>On Fri, 14 Sep 2001 01:01:28 +0800, "Tony Johnson"

>He means that the internal timer is stopped by the VB MsgBox but if
>you were using the MessageBox API then it may not do so. I dunno, i've
>never used the API from VB <shrug>

>If you're still having problems, it may be time to explain the
>workings of your code, or you may email me a copy of your project so i
>can look at what's happening.

>>Excuse my ignornace if i am wrong... but what the hell are you talking
>>about?

>>is a MsgBox different from a MessageBox, and how can this help me if it is?

>>re-scopped?

>>im new to all this... are you speaking VB?

>>FatTony,



>>> MsgBox or MessageBox ?

>>> Has somebody re-scoped your MsgBox ?

>>> On Thu, 13 Sep 2001 16:31:56 +0800, "Tony Johnson"

>>> >Yes... lots of timers about 6 or so to control the movement of objects..



>>> >> How is your game running - are you using any timers?

>>> >> J.



>>> >> > I am making a game, and after some comments from various testers,
>>they
>>> >> felt
>>> >> > they would like to pause the game during gameplay.  i though well
>>thats
>>> >> > easy... but alas it is not!

>>> >> > I thought that a simle Msgbox vbokonly would do the trick so i put
>>this
>>> >> code
>>> >> > in the keydown event.

>>> >> >     If KeyCode = 80 Or KeyCode = 19 Then
>>> >> >         MsgBox "Game Paused", vbOKOnly, "game Info"
>>> >> >     End If

>>> >> > that detects the pressing of the "p" key or the pause/break key and a
>>> >> > msgbox appears and the game is paused until ok is clicked. This works
>>> >> > perfectly at design time, but i was horrifie to discover that at
>>runtime
>>> >> the
>>> >> > game still runs behind the msgbox and it does not stop.

>>> >> > Can someone tell me why this is? I need s pause function.

>>> >> > I thought about using the Sleep API, but i wouldn't know how to wake
>>it
>>> >> > again because the program is asleep, not registering events.

>>> >> > Please Help.
>>> >> > Thanks

>>> >> > FatTony,
>>> >> > on VB6

>Regards, Frank



Tue, 02 Mar 2004 02:41:15 GMT  
 MsgBox pauses App at Design time but not run time
Tony

What Jim was asking about Timers for is that when in the IDE a MsgBox will
stop all timers from running, but when the app is compiled it doesn't.

What you should do is have a routine that disables all timers before showing
the MsgBox and then re-enable them when the MsgBox is dismissed.

regards

Ian

** invalid email address, change dk to denmark

homepage http://www.kingsoft-denmark.com/
Tips & Tricks page http://tips.kingsoft-denmark.com/


Quote:
> Yes... lots of timers about 6 or so to control the movement of objects..



> > How is your game running - are you using any timers?

> > J.

<snip>


Tue, 02 Mar 2004 02:30:18 GMT  
 MsgBox pauses App at Design time but not run time
Thanks Ian ! - I am amazed that I never noticed this before.

On Thu, 13 Sep 2001 19:30:18 +0100, "Ian Williams"

Quote:

>Tony

>What Jim was asking about Timers for is that when in the IDE a MsgBox will
>stop all timers from running, but when the app is compiled it doesn't.

>What you should do is have a routine that disables all timers before showing
>the MsgBox and then re-enable them when the MsgBox is dismissed.

>regards

>Ian

>** invalid email address, change dk to denmark

>homepage http://www.kingsoft-denmark.com/
>Tips & Tricks page http://tips.kingsoft-denmark.com/



>> Yes... lots of timers about 6 or so to control the movement of objects..



>> > How is your game running - are you using any timers?

>> > J.

><snip>



Tue, 02 Mar 2004 18:44:10 GMT  
 MsgBox pauses App at Design time but not run time
Thanks all that have helped me through this problem, my game is now complete
with pause function and all...

This is that final code that helped me.. after i realised MsgBoxes were
crap.  I used a label instead, and paused everything myself.

    'pause game
    If KeyCode = 80 Or KeyCode = 19 Then

        If tmBady.Enabled = True Then 'the end of level boss is active, no
pause
        Exit Sub
        End If
        If strPause = "yes" Then
            tmBrit.Enabled = True
            If strPause1 = "yes" Then
            tmFire1.Enabled = True
            End If
            If strPause2 = "yes" Then
            tmFire2.Enabled = True
            End If
            If strPause3 = "yes" Then
            tmFire3.Enabled = True
            End If
            strPause = "no"
        Else
            strPause = "yes"
            If tmFire1.Enabled = True Then 'firing 1st bullet
            strPause1 = "yes"
            End If
            If tmFire2.Enabled = True Then 'firing 2nd bullet
            strPause2 = "yes"
            End If
            If tmFire3.Enabled = True Then firing 3rd bullet
            strPause3 = "yes"
            End If
            Label8.Visible = True
            tmBady.Enabled = False
            tmBrit.Enabled = False
            tmFire1.Enabled = False
            tmFire2.Enabled = False
            tmFire3.Enabled = False
            tmLeft.Enabled = False
            tmRight.Enabled = False
        End If

    End If


Quote:
> Tony

> What Jim was asking about Timers for is that when in the IDE a MsgBox will
> stop all timers from running, but when the app is compiled it doesn't.

> What you should do is have a routine that disables all timers before
showing
> the MsgBox and then re-enable them when the MsgBox is dismissed.

> regards

> Ian

> ** invalid email address, change dk to denmark

> homepage http://www.kingsoft-denmark.com/
> Tips & Tricks page http://tips.kingsoft-denmark.com/



> > Yes... lots of timers about 6 or so to control the movement of objects..



> > > How is your game running - are you using any timers?

> > > J.

> <snip>



Wed, 03 Mar 2004 04:02:37 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Creating forms at run time, not design time.

2. Assign a treeview at design run time to other at design time

3. Code running in design time or run-time?

4. Runs in design mode, NOT Run Time.

5. Runs in Design Mode, NOT Run Time

6. web service and updating web reference with vb.net design time vs run time

7. getting run-time behavior of a contained control in a user control at design time

8. web service and updating web reference with vb.net design time vs run time

9. Design time vs Run time

10. Run Time vs Design Time - No Current Record

11. Design Time vs Run Time

12. design-time functionality at run-time

 

 
Powered by phpBB® Forum Software