[SDL] Unable to MessageBox...

John Popplewell john at johnnypops.demon.co.uk
Mon Jul 22 04:24:00 PDT 2002


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 );
 }
}

------------------------------------------------------>8-----

e.g.

SDL_Quit();
FlushMessageQueue();
iReturn = MessageBox(NULL, (const char *) "After SDL_Quit()", ....

cheers,
John.
PS this was originally posted back in May.




----- Original Message -----
From: "Neil Bradley" <nb at synthcom.com>
To: <sdl at libsdl.org>
Sent: Monday, July 22, 2002 4:22 AM
Subject: [SDL] Unable to MessageBox...


> > > program that does SDL_Initialize()/SDL_Quit() and anything afterward
> > > doesn't get executed.  Go figger.
> > What version operating system and compiler are you using?  Can you post
a
> > minimal compilable example that I can use to replicate the problem?
>
> Hi Sam -
>
> Sorry for taking eons to get back to you. I'm using MSVC++ 6.0 (SP2) under
> Windows 2000 and XP. Here's a quickie test program. I've found out (after
> tracing through it) that the app is *NOT* quitting prematurely, rather my
> MessageBox() commands aren't working. Here's the sample app:
>
> #define PROGRAM_TITLE "Test"
>
> int WINAPI WinMain(HINSTANCE eInst,
>    HINSTANCE ePreviousInstance,
>    LPSTR pu8CmdLine,
>    int s32CmdShow)
> {
> int iReturn;
>
> SDL_Init(SDL_INIT_VIDEO);
> iReturn = MessageBox(NULL, (const char *) "After SDL_Init()",
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
> SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE);
> iReturn = MessageBox(NULL, (const char *) "After SDL_SetVideoMode()",
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
> SDL_QuitSubSystem(SDL_INIT_VIDEO);
> iReturn = MessageBox(NULL, (const char *) "After SDL_QuitSubSystem()",
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
> SDL_Quit();
> iReturn = MessageBox(NULL, (const char *) "After SDL_Quit()",
PROGRAM_TITLE, MB_ICONSTOP | MB_OK);
> }
>
> I get the message boxes after SDL_Init() and SDL_VideoMode(), however
> after I do the SDL_QuitSubSystem(SDL_INIT_VIDEO), the "After
> SDL_QuitSubSystem()" message box returns a 1 (IDOK) immediately. It never
> displays the message box. Same deal after SDL_Quit(). The above example
> uses a windowed display - it makes no difference if it's full screen or
> windowed, but I'm running full screen with my game.
>
> It's driving me a bit crazy, because I'd like to be able to get messages
> back to my game players/beta testers after I've restored their desktop -
> asserts and the like. If I just do a MessageBox() in the middle of the
> game, most often the video mode causes it to be off the screen (I'm
> running full screen, BTW).
>
> Forgive me if this is Windows idiocy on my part, but I can't figure out
> what's going on, or why SQL_QuitSubSystem()/SQL_Quit() causes me to no
> longer be able to display message boxes.
>
> Thanks in advance!
>
> -->Neil
>
> --------------------------------------------------------------------------
-----
> Neil Bradley            What are burger lovers saying
> Synthcom Systems, Inc.  about the new BK Back Porch Griller?
> ICQ #29402898         "It tastes like it came off the back porch." - Me
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list