Jump to content
  • Advertisement
Sign in to follow this  
DaBono

SDL and MessageBox

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This seemed so simple, but somehow it got me stumped. I'm trying to use the Win32 MessageBox function in my SDL application, after the window has been created. However, after calling MessageBox I can't select my window (which makes sense, since my dialog is modal), but the dialog does not show up, and my game continues. I guess it has something to do with the fact that SDL handles my events, but how to fix this? Code:
bool WarningYesNoBox( char *msg )
{
   int ret = MessageBox( GetActiveWindow(), msg, "Warning", MB_YESNO | MB_ICONWARNING );
   return( ret == IDYES );
}

bool GameView::pumpEvents()
{
   SDL_Event event;
   while( SDL_PollEvent(&event) != 0 )
   {
      switch( event.type )
      {
          case SDL_MOUSEBUTTONDOWN:
               // [snip]... break;
          case SDL_KEYDOWN:
               // [snip]... break;
          case SDL_QUIT:
               return false;    // Stop the game..
          default:
               break;
      }
   }
   return true;
}

Share this post


Link to post
Share on other sites
Advertisement
This may not be the problem but whenever I used a message box in my SDL stuff I passed NULL for the HWND parameter instead of calling GetActiveWindow(). This always worked fine for me and I didn't encounter any problems like you've described.

Share this post


Link to post
Share on other sites
Quote:
Original post by Spudder
This may not be the problem but whenever I used a message box in my SDL stuff I passed NULL for the HWND parameter instead of calling GetActiveWindow(). This always worked fine for me and I didn't encounter any problems like you've described.


Same here, NULL works perfectly for me.

Passing in NULL means that the MessageBox isn't referring back to a parent window, passing in something other than NULL is only useful if you're working with an MDI app.

Share this post


Link to post
Share on other sites
I had NULL previously, but the only difference was that I could select my window as normal (since modality doesn't work without a parent window).

Alas.. Now I changed my error message to appear before my window is created, and there's absolutely no problem. Looks better anyway, so I'll stick with this.
Thanks for helping though!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!