src/video/windib/SDL_dibevents.c
changeset 974 b8427b5151ed
parent 833 31fa08b36380
child 975 add87cc1de0a
     1.1 --- a/src/video/windib/SDL_dibevents.c	Mon Nov 15 01:47:53 2004 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Mon Nov 15 21:09:54 2004 +0000
     1.3 @@ -369,13 +369,16 @@
     1.4  	if ( SDL_windowid ) {
     1.5  		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
     1.6  
     1.7 -      /* DJM: we want all event's for the user specified
     1.8 -         window to be handled by SDL.
     1.9 -       */
    1.10 -      if (SDL_Window) {
    1.11 -         userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
    1.12 -         SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
    1.13 -      }
    1.14 +		if ( SDL_Window == NULL ) {
    1.15 +			SDL_SetError("Couldn't get user specified window");
    1.16 +			return(-1);
    1.17 +		}
    1.18 +
    1.19 +		/* DJM: we want all event's for the user specified
    1.20 +			window to be handled by SDL.
    1.21 +		 */
    1.22 +		userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
    1.23 +		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
    1.24  	} else {
    1.25  		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
    1.26                          (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
    1.27 @@ -391,7 +394,9 @@
    1.28  
    1.29  void DIB_DestroyWindow(_THIS)
    1.30  {
    1.31 -	if ( SDL_windowid == NULL ) {
    1.32 +	if ( SDL_windowid ) {
    1.33 +		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc);
    1.34 +	} else {
    1.35  		DestroyWindow(SDL_Window);
    1.36  	}
    1.37  }