Windows key crashes app

hello,

in my app i setup SDL and get a pointer to the screen, then i go about
printing things to the screen by:

Uint32 *screenptr = (Uint32 *)screen->pixels;
*screenptr = kolor;

however, when the user hits the windows key or alt-tabs to bring up
windows, my program will stop running. how can i either disable the windows
key or alt-tab ability of the user. or how can i make my program where it
wont stop when windows gets focus and my program gets minimized? any
suggestions would be greatly appreciated. :slight_smile:

  • jeremiah

windows key crashes appdid you try checking to make sure screen->pixels isnt NULL before you write to it? I dont know if when your surface is lost if it sets the pointer to NULL, but that sure would be the polite thing to do :P----- Original Message -----
From: Martell, Jeremiah
To: 'sdl at libsdl.org
Sent: Wednesday, April 23, 2003 12:07 PM
Subject: [SDL] windows key crashes app

hello,

in my app i setup SDL and get a pointer to the screen, then i go about printing things to the screen by: 

Uint32 *screenptr = (Uint32 *)screen->pixels;
*screenptr = kolor;

however, when the user hits the windows key or alt-tabs to bring up windows, my program will stop running. how can i either disable the windows key or alt-tab ability of the user. or how can i make my program where it wont stop when windows gets focus and my program gets minimized? any suggestions would be greatly appreciated. :)
  • jeremiah

ok,

i figured out how to get around this. it was rather easy and i cant
believe i missed it, but oh well. you just need to check for the
SDL_ACTIVEEVENT, which tells you if your app gains or looses focus. so i
just quit drawing when i loose focus, and start drawing again when i gain it
back. :slight_smile:

  • jeremiah> ----- Original Message -----

From: Martell, Jeremiah
To: 'sdl at libsdl.org
Sent: 4/23/2003 3:07 PM
Subject: [SDL] windows key crashes app

hello,

in my app i setup SDL and get a pointer to the screen, then i go about
printing things to the screen by:

Uint32 *screenptr = (Uint32 *)screen->pixels;
*screenptr = kolor;

however, when the user hits the windows key or alt-tabs to bring up
windows, my program will stop running. how can i either disable the
windows key or alt-tab ability of the user. or how can i make my program
where it wont stop when windows gets focus and my program gets
minimized? any suggestions would be greatly appreciated. :slight_smile:

  • jeremiah

Martell, Jeremiah wrote:

however, when the user hits the windows key or alt-tabs to bring up
windows, my program will stop running. how can i either disable the
windows key or alt-tab ability of the user. or how can i make my program
where it wont stop when windows gets focus and my program gets
minimized? any suggestions would be greatly appreciated. :slight_smile:

Try something like:

if(!SDL_LockSurface(screen)) {
Uint32 *screenptr = (Uint32 *)screen->pixels;
*screenptr = kolor;
SD_UnlockSurface(screen);
}

Bye,
Gabry