Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
authorSam Lantinga <slouken@libsdl.org>
Thu, 09 Aug 2001 14:04:46 +0000
changeset 1490e66fd980014
parent 148 8758b8d42cd9
child 150 df1d68818edb
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
include/SDL_main.h
src/main/win32/SDL_main.c
src/video/wincommon/SDL_sysevents.c
     1.1 --- a/include/SDL_main.h	Thu Aug 09 13:09:47 2001 +0000
     1.2 +++ b/include/SDL_main.h	Thu Aug 09 14:04:46 2001 +0000
     1.3 @@ -64,9 +64,9 @@
     1.4  #endif
     1.5  
     1.6  /* This should be called from your WinMain() function, if any */
     1.7 -extern DECLSPEC void SDL_SetModuleHandle(HMODULE hInst);
     1.8 +extern DECLSPEC void SDL_SetModuleHandle(void *hInst);
     1.9  /* This can also be called, but is no longer necessary */
    1.10 -extern DECLSPEC int SDL_RegisterApp(char *name, Uint32 style, HMODULE hInst);
    1.11 +extern DECLSPEC int SDL_RegisterApp(char *name, Uint32 style, void *hInst);
    1.12  
    1.13  #ifdef __cplusplus
    1.14  }
     2.1 --- a/src/main/win32/SDL_main.c	Thu Aug 09 13:09:47 2001 +0000
     2.2 +++ b/src/main/win32/SDL_main.c	Thu Aug 09 14:04:46 2001 +0000
     2.3 @@ -199,16 +199,25 @@
     2.4  	atexit(SDL_Quit);
     2.5  
     2.6  #ifndef DISABLE_VIDEO
     2.7 +#if 0
     2.8  	/* Create and register our class *
     2.9 -      DJM: If we do this here, the user nevers gets a chance to
    2.10 -      putenv(SDL_WINDOWID).  This is already called later by
    2.11 -      the (DIB|DX5)_CreateWindow function, so it should be
    2.12 -      safe to comment it out here.
    2.13 +	   DJM: If we do this here, the user nevers gets a chance to
    2.14 +	   putenv(SDL_WINDOWID).  This is already called later by
    2.15 +	   the (DIB|DX5)_CreateWindow function, so it should be
    2.16 +	   safe to comment it out here.
    2.17  	if ( SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT, 
    2.18  	                     GetModuleHandle(NULL)) < 0 ) {
    2.19  		ShowError("WinMain() error", SDL_GetError());
    2.20  		exit(1);
    2.21  	}*/
    2.22 +#else
    2.23 +	/* Sam:
    2.24 +	   We still need to pass in the application handle so that
    2.25 +	   DirectInput will initialize properly when SDL_RegisterApp()
    2.26 +	   is called later in the video initialization.
    2.27 +	 */
    2.28 +	SDL_SetModuleHandle(GetModuleHandle(NULL));
    2.29 +#endif /* 0 */
    2.30  #endif /* !DISABLE_VIDEO */
    2.31  
    2.32  	/* Run the application main() code */
     3.1 --- a/src/video/wincommon/SDL_sysevents.c	Thu Aug 09 13:09:47 2001 +0000
     3.2 +++ b/src/video/wincommon/SDL_sysevents.c	Thu Aug 09 14:04:46 2001 +0000
     3.3 @@ -504,13 +504,13 @@
     3.4  }
     3.5  
     3.6  /* Allow the application handle to be stored and retrieved later */
     3.7 -static HMODULE SDL_handle = NULL;
     3.8 +static void *SDL_handle = NULL;
     3.9  
    3.10 -void SDL_SetModuleHandle(HMODULE handle)
    3.11 +void SDL_SetModuleHandle(void *handle)
    3.12  {
    3.13  	SDL_handle = handle;
    3.14  }
    3.15 -HMODULE SDL_GetModuleHandle(void)
    3.16 +void *SDL_GetModuleHandle(void)
    3.17  {
    3.18  	void *handle;
    3.19  
    3.20 @@ -531,7 +531,7 @@
    3.21  const char *SDL_windowid = NULL;
    3.22  
    3.23  /* Register the class for this application -- exported for winmain.c */
    3.24 -int SDL_RegisterApp(char *name, Uint32 style, HMODULE hInst)
    3.25 +int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
    3.26  {
    3.27  	static int initialized = 0;
    3.28  	WNDCLASS class;
    3.29 @@ -571,7 +571,7 @@
    3.30  	class.lpszClassName	= name;
    3.31  #endif /* _WIN32_WCE */
    3.32  	class.hbrBackground	= NULL;
    3.33 -	class.hInstance		= hInst ? hInst : GetModuleHandle(0);
    3.34 +	class.hInstance		= hInst;
    3.35  	class.style		= style;
    3.36  #ifdef HAVE_OPENGL
    3.37  	class.style		|= CS_OWNDC;