Restore the user specified window proc after shutdown
authorSam Lantinga <slouken@libsdl.org>
Mon, 15 Nov 2004 21:09:54 +0000
changeset 974 b8427b5151ed
parent 973 795ac5fbe260
child 975 add87cc1de0a
Restore the user specified window proc after shutdown
src/video/windib/SDL_dibevents.c
--- a/src/video/windib/SDL_dibevents.c	Mon Nov 15 01:47:53 2004 +0000
+++ b/src/video/windib/SDL_dibevents.c	Mon Nov 15 21:09:54 2004 +0000
@@ -369,13 +369,16 @@
 	if ( SDL_windowid ) {
 		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
 
-      /* DJM: we want all event's for the user specified
-         window to be handled by SDL.
-       */
-      if (SDL_Window) {
-         userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
-         SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
-      }
+		if ( SDL_Window == NULL ) {
+			SDL_SetError("Couldn't get user specified window");
+			return(-1);
+		}
+
+		/* DJM: we want all event's for the user specified
+			window to be handled by SDL.
+		 */
+		userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
+		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
 	} else {
 		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
                         (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
@@ -391,7 +394,9 @@
 
 void DIB_DestroyWindow(_THIS)
 {
-	if ( SDL_windowid == NULL ) {
+	if ( SDL_windowid ) {
+		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc);
+	} else {
 		DestroyWindow(SDL_Window);
 	}
 }