I wanted to include a window mode for widescreen monitors to preserve the aspect ratio. However, in the shooting action the mouse would get outside of the window and minimize the game window. My workaround is to use this snippet by Mercuryus which keeps the aspect ration of the game at 4/3.

I just got a widescreen monitor a couple days ago and the code works very well.