By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

Message box

P: n/a
Hi all,

These are the best places I can find to ask this, I can't find a good Visual
C++ ng.

I've written a program in Visual C++, which is a board game, so has a fair
amount of input from the user.

In the 'WM_PAINT' event I call a routine to draw certain shapes. I have an
MB_OK message box which pops up to indicate an error, and I want to suspend
all action of the program (i.e. disable the event handler) until the the
user acknowledges the message box by clicking 'Ok' or closing it.

I tried using a 'do' loop with the message box successful return as the
condition, or an endless for loop with a break, etc., however, the event
queue still overrides the action, and the user can still click on the screen
and it goes into the 'WM_LBUTTONDOWN' event.

Is there a way I can fix this, short of setting a flag when the messagebox
is acknowleged, and putting an 'if' in all my events to check if the flag?

Thank in advance,
Wawa
Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Wawa wrote:
Hi all,

These are the best places I can find to ask this, I can't find a good
Visual C++ ng.


comp.lang.c++ is not the best place, since here, we only deal with the
C++ language as defined by the ISO standard, which doesn't cover
message boxes or anything that is system dependant.

Jul 19 '05 #2

P: n/a
On Sun, 3 Aug 2003 01:24:02 +0100, "Wawa"
<S.***********@student.lboro.ac.uk> wrote:
Hi all,

These are the best places I can find to ask this, I can't find a good Visual
C++ ng.
This is no good place to ask this. comp.lang.c++ talks only about
Standard C++, which has nothing to do with Windows.
In the 'WM_PAINT' event I call a routine to draw certain shapes. I have an
MB_OK message box which pops up to indicate an error, and I want to suspend
all action of the program (i.e. disable the event handler) until the the
user acknowledges the message box by clicking 'Ok' or closing it.


<ot>

Well you could set a flag when an error message pops up and and check
this flag in the loop in WinMain.. that would be quite easy, no?

</ot>

Jonathan

Jul 19 '05 #3

P: n/a
> These are the best places I can find to ask this, I can't find a good
Visual
C++ ng.


What, not even the 22+ VC++ newsgroups on Microsoft's own news server, not
counting even the non-English speaking VC++ newsgroups?
Visit News Server: msnews.microsoft.com

Stephen Howe
Jul 19 '05 #4

P: n/a
> This is no good place to ask this. comp.lang.c++ talks only about
Standard C++, which has nothing to do with Windows.
Do loops, while loops and flags are standard C, and that was the basis of my
post, but let's not get pedantic. There's so many newsgroups it's sometimes
hard to find an appropriate one, and people's reaction if you don't suceed
are never helpful.

<ot>

Well you could set a flag when an error message pops up and and check
this flag in the loop in WinMain.. that would be quite easy, no?

</ot>


In my original post I wrote:
"Is there a way I can fix this, short of setting a flag when the messagebox
is acknowleged, and putting an 'if' in all my events to check if the flag?"

so I had considered that option already.
Jul 19 '05 #5

P: n/a
On Sun, 3 Aug 2003 03:07:47 +0100, "Wawa"
<S.***********@student.lboro.ac.uk> wrote:
This is no good place to ask this. comp.lang.c++ talks only about
Standard C++, which has nothing to do with Windows.
Do loops, while loops and flags are standard C,


You should choose wether you are programming in C++ or C.
and that was the basis of my
post, but let's not get pedantic. There's so many newsgroups it's sometimes
hard to find an appropriate one, and people's reaction if you don't suceed
are never helpful.


Suceeding is not that difficult. Just pick a newsgroup directly
related to your question. If your question is about loops and flags,
then it is welcomed here.
<ot>

Well you could set a flag when an error message pops up and and check
this flag in the loop in WinMain.. that would be quite easy, no?

</ot>


In my original post I wrote:
"Is there a way I can fix this, short of setting a flag when the messagebox
is acknowleged, and putting an 'if' in all my events to check if the flag?"

so I had considered that option already.


To quote you myself :

"[..] and putting an 'if' in all my events to check if the flag?"

You only need to put the test in the main loop and that's it.
Basically, you want a 'pause' feature :

int main()
{
bool pause = false;

// main loop
while ( true )
{
if ( paused() ) pause = true;
if ( unpaused() ) pause = false;

if (pause) continue;

// other handling
}
}
If you want a solution which concerns the windows api, please do not
post in standard c++ newsgroups.
Jonathan

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.