This makes sense - you're running in fullscreen mode - it has to give the message window focus and show the desktop again. Use SetFocus to restore it.
I see. I guess I thought it would work somehow. I'll just write my own function for that. It would look nicer if I done it myself anyhow. I only use it for the level editor actually so, I guess I could even just limit the editor to Windowed or Fullscreen Windowed mode. Not that big of a deal really. If I ever need it for the main game itself I'll write my own function for it.
things happening or not happening depending on debug mode tends to be caused by uninitialized variables, or in rare-er cases, memory corruption.
I was very careful to initialize all variables and destroy them. As I developed this, when I made a variable that needed to be destroyed later (like an 'ALLEGRO_BITMAP' for example) I always initialized it with a NULL when declaring it, and then the first thing I did was add it to a shutdown() function I have that destroys it (and sets it to NULL afterwards to be safe).
I think it has more to do with debug version is a console app, and the release is a GUI. It works fine on Windows 7 and I can't understand how it would lose focus and not be able to get it back without clicking on the window manually. It runs fine otherwise. If I can't figure this out, I'll not bother and just leave it as a pain in the butt item for XP users as my patience on this is wearing thin.
If it wasn't for certain features of Allegro 5 I like so much, I would be tempted to go back to Allegro 4.
Edit: After more tests I put in a al_rest(15) early in my code, basically in my main() function I jump to an initialization function which then sets up PHYSFS, then the display screen and loads in various data (fonts, graphics etc). So the rest I threw in right after the display was set and during the 15 second pause it lost focus. I am beginning to wonder if it doesn't have something to do with PHYSFS maybe? It's about the only thing that gets initialized aside from the screen.
Edit: Okay, I just tested the program with PHYSFS commented out. All the game does is the usual allegro initialization functions...
And I set up some variables I intend to use. I checked them all and they are all set to default values to start (= NULL etc) but none of them are actually used at this point and it still loses focus. There's nothing left for me to test. I'll have to write an Allegro plain APP that opens a window and see what that does I guess.
YAY!!! I found the line that is causing the problem!!!
I ran my level editor which basically consists of a main function and not too much more and noticed it was doing the same thing. This made it easier for me to narrow down the problem. SO, I started commenting out lines until it stopped happening.
When I commented out this line, the problem went away...
Somehow, THIS line causes my programs to lose focus about 3 seconds after they have been run. I'm totally baffled. It only happens on my wife's WindowsXP machine. I don't know if it's her video card or what it could be. She has an older GeForce FX5200 in her system. I DO plan to give it a minor upgrade soon, but I would be curious as to why this would cause a program to lose focus.