MessageBox after SDL_Quit

Hi there,

When my demo is done I would like to show a message in a message box, but
the message box will NOT show no matter WHAT I do… This is what I’m
trying:

SDL_Quit();


{
	char str[256];
	sprintf(str, "flags %08x", myFlags);
	int res = MessageBox(NULL, str, "Hm", MB_YESNO|MB_SYSTEMMODAL);
}

res always return the ID of the first button, so in the above it would be
IDYES.

Anyone got any idea why ?

best,

Sam

Hi,

I had a problem with this a while back when trying to pop-up an
error message box after the windows message-loop had quit.

Flushing the message-queue seemed to work :

-----8<------------------------------------------------------

void FlushMessageQueue()
{
MSG msg;

while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT ) break;
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}

SDL_Quit();

{
char str[256];
sprintf(str, “flags %08x”, myFlags);
FlushMessageQueue();
int res = MessageBox(NULL, str, “Hm”, MB_YESNO|MB_SYSTEMMODAL);
}

-----8<------------------------------------------------------

I haven’t tried the above code, but I think it made it work for
me.

(Windows seems to have turned me into a “bodge-it” merchant …)

cheers,
John.> ----- Original Message -----

From: sam@novalicious.com (Sam Nova)
To:
Sent: Monday, May 13, 2002 10:25 PM
Subject: [SDL] MessageBox after SDL_Quit

Hi there,

When my demo is done I would like to show a message in a message box, but
the message box will NOT show no matter WHAT I do… This is what I’m
trying:

SDL_Quit();

{
char str[256];
sprintf(str, “flags %08x”, myFlags);
int res = MessageBox(NULL, str, “Hm”, MB_YESNO|MB_SYSTEMMODAL);
}

res always return the ID of the first button, so in the above it would be
IDYES.

Anyone got any idea why ?

best,

Sam


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

| Hi,
|
| I had a problem with this a while back when trying to pop-up an
| error message box after the windows message-loop had quit.
|
| Flushing the message-queue seemed to work :

Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
function…On Mon, May 13, 2002 at 11:57:54PM +0100, John Popplewell wrote:


This is not a clue… or is it?

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

Hi,

Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
function…

Yes.

This fudge is for a Windows-only problem. Just trying to help a fellow
sufferer. Perhaps this is on the wrong list, sorry,

cheers,
John.> ----- Original Message -----

From: james@piku.org.uk (James)
To:
Sent: Tuesday, May 14, 2002 12:24 AM
Subject: Re: [SDL] MessageBox after SDL_Quit

On Mon, May 13, 2002 at 11:57:54PM +0100, John Popplewell wrote:
| Hi,
|
| I had a problem with this a while back when trying to pop-up an
| error message box after the windows message-loop had quit.
|
| Flushing the message-queue seemed to work :

Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
function…


This is not a clue… or is it?

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi John,

Thanks. The code worked without a problem. I would almost say that this
could be described as a SDL bug, not cleaning up… (or a windows bug).

Best,

Sam> I had a problem with this a while back when trying to pop-up an

error message box after the windows message-loop had quit.

Flushing the message-queue seemed to work :

-----8<------------------------------------------------------

void FlushMessageQueue()
{
MSG msg;

while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT ) break;
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}

SDL_Quit();

{
char str[256];
sprintf(str, “flags %08x”, myFlags);
FlushMessageQueue();
int res = MessageBox(NULL, str, “Hm”, MB_YESNO|MB_SYSTEMMODAL);
}

-----8<------------------------------------------------------

I haven’t tried the above code, but I think it made it work for
me.

(Windows seems to have turned me into a “bodge-it” merchant …)

cheers,
John.

----- Original Message -----
From: “Sam Nova” <@Sam_Nova>
To:
Sent: Monday, May 13, 2002 10:25 PM
Subject: [SDL] MessageBox after SDL_Quit

Hi there,

When my demo is done I would like to show a message in a
message box, but
the message box will NOT show no matter WHAT I do… This is what I’m
trying:

SDL_Quit();

{
char str[256];
sprintf(str, “flags %08x”, myFlags);
int res = MessageBox(NULL, str, “Hm”, MB_YESNO|MB_SYSTEMMODAL);
}

res always return the ID of the first button, so in the above
it would be
IDYES.

Anyone got any idea why ?

best,

Sam


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  1. Just becasue I’m using SDL does not mean I want my code to be portable,
    right ? (probably will at some stage)

  2. The thing I’m using MessageBox for right now is just for getting some
    debug information for myself when the code is done.

  3. Is there a generic way to show a window with some text ? A portable way
    !!

-Sam> On Mon, May 13, 2002 at 11:57:54PM +0100, John Popplewell wrote:

| Hi,
|
| I had a problem with this a while back when trying to pop-up an
| error message box after the windows message-loop had quit.
|
| Flushing the message-queue seemed to work :

Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
function…

| > On Mon, May 13, 2002 at 11:57:54PM +0100, John Popplewell wrote:
| > | Hi,
| > |
| > | I had a problem with this a while back when trying to pop-up an
| > | error message box after the windows message-loop had quit.
| > |
| > | Flushing the message-queue seemed to work :
| >
| > Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
| > function…
|
| 1. Just becasue I’m using SDL does not mean I want my code to be portable,
| right ? (probably will at some stage)
|
| 2. The thing I’m using MessageBox for right now is just for getting some
| debug information for myself when the code is done.
|
| 3. Is there a generic way to show a window with some text ? A portable way
| !!

Why not just use a printf() and then check stdout.txt?On Tue, May 14, 2002 at 08:45:44AM +0200, Sam Nova wrote:


Life is complex – it has both real and imaginary parts

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

:slight_smile: I do that now… thanks…

But still, what do people do if SDL_Init fails ? You can’t tell the user in
the manual to check stdout.txt for problems !!! Then again, a general way of
showing a error message might be beyond the ideas with SDL !!!

-Sam> On Tue, May 14, 2002 at 08:45:44AM +0200, Sam Nova wrote:

| > On Mon, May 13, 2002 at 11:57:54PM +0100, John Popplewell wrote:
| > | Hi,
| > |
| > | I had a problem with this a while back when trying to pop-up an
| > | error message box after the windows message-loop had quit.
| > |
| > | Flushing the message-queue seemed to work :
| >
| > Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
| > function…
|
| 1. Just becasue I’m using SDL does not mean I want my code to
be portable,
| right ? (probably will at some stage)
|
| 2. The thing I’m using MessageBox for right now is just for getting some
| debug information for myself when the code is done.
|
| 3. Is there a generic way to show a window with some text ? A
portable way
| !!

Why not just use a printf() and then check stdout.txt?

Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
function…

  1. Just becasue I’m using SDL does not mean I want my code to be portable,
    right ? (probably will at some stage)

Actually, we’re using MessageBox() as well and our code is quite portable.
We just don’t use it elsewhere. And last time I looked, that particular
thing was broken because SDL_Quit seems to kill off the program before the
message box is displayed with the reason why for most people. Not had a
chance to really try this out yet. May feed the DynGL code something
really broken to test it.

  1. The thing I’m using MessageBox for right now is just for getting some
    debug information for myself when the code is done.

That’s quite fine, just mark it with a FIXME comment so you can search for
it later easily. You don’t have to listen to me of course, but it’s
basically a good idea.

  1. Is there a generic way to show a window with some text ? A portable way
    !!

'fraid not. Here’s the best I can do:

void
System_Error (char *error, …)
{
va_list argptr;
char text[4096];

va_start (argptr, error);
vsnprintf (text, sizeof (text), error, argptr);
va_end (argptr); 

// Shut down the system if we can
System_Shutdown ();

#ifdef HAVE_FCNTL
// change stdin to non blocking
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
#endif

#ifdef _WIN32
// Win32 gets a GUI message box
MessageBox (NULL, text, “Error”, 0);
#else
fprintf (stderr, “Error: %s\n”, text);
#endif

// This function does nothing unless you have execinfo.h
System_BackTrace (2);

// Should already have been called
SDL_Quit ();

// That's about all we can do...
exit (1);

}

This is sufficient for our purposes since we currently only support Win32,
Linux, and MacOS X. I am willing to work on a more generic messagebox
function that supports more platforms and add it to the pile of useful
things for SDL programmers page I’ve started working on. URL when there
is a good bit of content there - I haven’t even got a working gen 3 DynGL
written for the page yet. =(On Tue, May 14, 2002 at 08:45:44AM +0200, Sam Nova wrote:


Joseph Carter My opinions are always right

I invoke Espy’s law, which states that you all suck :stuck_out_tongue:

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020514/46215171/attachment.pgp

But still, what do people do if SDL_Init fails ? You can’t tell the user
in
the manual to check stdout.txt for problems !!! Then again, a general way
of
showing a error message might be beyond the ideas with SDL !!!

I was thinking that same thing… but then I figured that we would start to
rapidly enter the relms of Java by doing stuff like that :slight_smile:

  1. Just becasue I’m using SDL does not mean I want my code to be portable,
    right ? (probably will at some stage)

It’s much easier if you think about portability all along…

  1. The thing I’m using MessageBox for right now is just for getting some
    debug information for myself when the code is done.
  2. Is there a generic way to show a window with some text ? A portable way

Try “printf” (or fprintf to stderr). In Windows, you might have to rebuild
SDL with --disable-stdio-redirect (unless checking a file afterwards is
acceptable). This is a time-honored debugging strategy. :)On Tue, May 14, 2002 at 08:45:44AM +0200, Sam Nova wrote:


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/

“Sweeney, Steven (FNB)” wrote:

But still, what do people do if SDL_Init fails ? You can’t tell the user
in
the manual to check stdout.txt for problems !!! Then again, a general way
of
showing a error message might be beyond the ideas with SDL !!!

I was thinking that same thing… but then I figured that we would start to
rapidly enter the relms of Java by doing stuff like that :slight_smile:

I disagree. Program has to be able to output a message to user.
In fact , at least two types of messages are needed: information and error.
This usually means printing to stdout or stderr, but that is just not the
best choice for many platforms.
SDL currently doesn’t provide a way to do this portably.
But do the functions for outputting messages portably belong to SDL?
I think yes because SDL, as a multimedia library, serves as a basic
interface between user and program.

I disagree. Program has to be able to output a message to user.
In fact , at least two types of messages are needed: information
and error.
This usually means printing to stdout or stderr, but that is just not the
best choice for many platforms.

And that is NOT user friendly anyway. It is okay for us programmers but not
for normal users.

SDL currently doesn’t provide a way to do this portably.
But do the functions for outputting messages portably belong to SDL?
I think yes because SDL, as a multimedia library, serves as a basic
interface between user and program.

I would be very happy to see this in SDL, some simple functions for giving
the user information (such as errors).

-Sam

| > I disagree. Program has to be able to output a message to user.
| > In fact , at least two types of messages are needed: information
| > and error.
| > This usually means printing to stdout or stderr, but that is just not the
| > best choice for many platforms.
|
| And that is NOT user friendly anyway. It is okay for us programmers but not
| for normal users.
|
| > SDL currently doesn’t provide a way to do this portably.
| > But do the functions for outputting messages portably belong to SDL?
| > I think yes because SDL, as a multimedia library, serves as a basic
| > interface between user and program.
|
| I would be very happy to see this in SDL, some simple functions for giving
| the user information (such as errors).

How would these work on targets that don’t have the concept of a
"window"? Like the SVGAlib, directfb(?) or PDAs?

I suppose if the backend handed the actual display of a
"SDL_MessageBox" or whatever, then all would be well :)On Tue, May 14, 2002 at 05:58:56PM +0200, Sam Nova wrote:


Bart Bucks are not legal tender

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

SDL currently doesn’t provide a way to do this portably.
But do the functions for outputting messages portably belong to SDL?
I think yes because SDL, as a multimedia library, serves as a basic
interface between user and program.

I would be very happy to see this in SDL, some simple functions for giving
the user information (such as errors).

You know, lots of people have asked for this, but nobody has actually
written any robust method for doing this. I’m not opposed to adding it
to SDL 2.0, but it would sure help if somebody actually submitted code.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

14/05/02 1.24.08, James wrote:>On Mon, May 13, 2002 at 11:57:54PM +0100, John Popplewell wrote:

| Hi,
|
| I had a problem with this a while back when trying to pop-up an
| error message box after the windows message-loop had quit.
|
| Flushing the message-queue seemed to work :

Wouldn’t this make your code non-portable? “MessageBox()” is a Windows
function…

Regarding this, I think that it would take Sam no more than 10 minutes to add an SDL_Message function. (Maybe I’m
wrong, I don’t know how it works on other OSs).

Hi John,

Thanks. The code worked without a problem. I would almost say that this
could be described as a SDL bug, not cleaning up… (or a windows bug).

Sam, I seem not to find the message you’re replying to here… Which John
do I credit for this code? I’ve just applied it to my stuff, but haven’t
credited the change properly yet.On Tue, May 14, 2002 at 08:45:45AM +0200, Sam Nova wrote:

-----8<------------------------------------------------------

void FlushMessageQueue()
{
MSG msg;

while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT ) break;
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}


Joseph Carter Certified free software nut

That’s the funniest thing I’ve ever heard and I will not condone it.
– DyerMaker, 17 March 2000 MegaPhone radio show

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020514/769e5445/attachment.pgp

| I would be very happy to see this in SDL, some simple functions for giving
| the user information (such as errors).

How would these work on targets that don’t have the concept of a
"window"? Like the SVGAlib, directfb(?) or PDAs?

For targets that cannot use stderr effectively, a GUI messagebox for error
messages is highly appropriate. I have something like this I will be
putting up on a page in a few days with a few other useful SDL snippets
like my gen 3 DynGL code. (Note, I expect gen 3 to be the final
generation of this code prior to OpenGL 2.0’s widespread adoptance…)

I suppose if the backend handed the actual display of a
"SDL_MessageBox" or whatever, then all would be well :slight_smile:

I’m calling it SDL_SL_ErrorMsg (), intended for fatal error messages,
called just before SDL_Quit () (or just after, as you like it…)

Um, anyone here happen to use emacs? I need a cmode tag for a 4 space
hard tab indent, equiv of ft=c ts=4 sw=4 in vim… Advice welcome.On Tue, May 14, 2002 at 06:05:02PM +0100, James wrote:


Joseph Carter Available in cherry and grape

Guns don’t kill people. It’s those damn bullets. Guns just make them go
really really fast.
– Jake Johanson

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020514/93702137/attachment.pgp

Just looked at the emails with the same subject and found it was from John
Popplewell [john at johnnypops.demon.co.uk]

Best,

Sam> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Joseph Carter
Sent: Tuesday, May 14, 2002 10:59 PM
To: sdl at libsdl.org
Subject: Re: [SDL] MessageBox after SDL_Quit

On Tue, May 14, 2002 at 08:45:45AM +0200, Sam Nova wrote:

Hi John,

Thanks. The code worked without a problem. I would almost say that this
could be described as a SDL bug, not cleaning up… (or a windows bug).

Sam, I seem not to find the message you’re replying to here… Which John
do I credit for this code? I’ve just applied it to my stuff, but haven’t
credited the change properly yet.

-----8<------------------------------------------------------

void FlushMessageQueue()
{
MSG msg;

while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT ) break;
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}


Joseph Carter Certified free software nut

That’s the funniest thing I’ve ever heard and I will not condone it.
– DyerMaker, 17 March 2000 MegaPhone radio show

Thanks, credited.On Tue, May 14, 2002 at 11:53:16PM +0200, Sam Nova wrote:

Just looked at the emails with the same subject and found it was from John
Popplewell [john at johnnypops.demon.co.uk]


Joseph Carter Goldfish don’t bounce

aggh!
MAKE IT STOP!
MAKE IT STOP!!

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020514/ffc290fa/attachment.pgp