Commit 8e41c231 authored by Sam Lantinga's avatar Sam Lantinga

Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40150
parent 2aca7272
...@@ -64,9 +64,9 @@ extern "C" { ...@@ -64,9 +64,9 @@ extern "C" {
#endif #endif
/* This should be called from your WinMain() function, if any */ /* This should be called from your WinMain() function, if any */
extern DECLSPEC void SDL_SetModuleHandle(HMODULE hInst); extern DECLSPEC void SDL_SetModuleHandle(void *hInst);
/* This can also be called, but is no longer necessary */ /* This can also be called, but is no longer necessary */
extern DECLSPEC int SDL_RegisterApp(char *name, Uint32 style, HMODULE hInst); extern DECLSPEC int SDL_RegisterApp(char *name, Uint32 style, void *hInst);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -199,6 +199,7 @@ int console_main(int argc, char *argv[]) ...@@ -199,6 +199,7 @@ int console_main(int argc, char *argv[])
atexit(SDL_Quit); atexit(SDL_Quit);
#ifndef DISABLE_VIDEO #ifndef DISABLE_VIDEO
#if 0
/* Create and register our class * /* Create and register our class *
DJM: If we do this here, the user nevers gets a chance to DJM: If we do this here, the user nevers gets a chance to
putenv(SDL_WINDOWID). This is already called later by putenv(SDL_WINDOWID). This is already called later by
...@@ -209,6 +210,14 @@ int console_main(int argc, char *argv[]) ...@@ -209,6 +210,14 @@ int console_main(int argc, char *argv[])
ShowError("WinMain() error", SDL_GetError()); ShowError("WinMain() error", SDL_GetError());
exit(1); exit(1);
}*/ }*/
#else
/* Sam:
We still need to pass in the application handle so that
DirectInput will initialize properly when SDL_RegisterApp()
is called later in the video initialization.
*/
SDL_SetModuleHandle(GetModuleHandle(NULL));
#endif /* 0 */
#endif /* !DISABLE_VIDEO */ #endif /* !DISABLE_VIDEO */
/* Run the application main() code */ /* Run the application main() code */
......
...@@ -504,13 +504,13 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -504,13 +504,13 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
/* Allow the application handle to be stored and retrieved later */ /* Allow the application handle to be stored and retrieved later */
static HMODULE SDL_handle = NULL; static void *SDL_handle = NULL;
void SDL_SetModuleHandle(HMODULE handle) void SDL_SetModuleHandle(void *handle)
{ {
SDL_handle = handle; SDL_handle = handle;
} }
HMODULE SDL_GetModuleHandle(void) void *SDL_GetModuleHandle(void)
{ {
void *handle; void *handle;
...@@ -531,7 +531,7 @@ HMODULE SDL_GetModuleHandle(void) ...@@ -531,7 +531,7 @@ HMODULE SDL_GetModuleHandle(void)
const char *SDL_windowid = NULL; const char *SDL_windowid = NULL;
/* Register the class for this application -- exported for winmain.c */ /* Register the class for this application -- exported for winmain.c */
int SDL_RegisterApp(char *name, Uint32 style, HMODULE hInst) int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
{ {
static int initialized = 0; static int initialized = 0;
WNDCLASS class; WNDCLASS class;
...@@ -571,7 +571,7 @@ int SDL_RegisterApp(char *name, Uint32 style, HMODULE hInst) ...@@ -571,7 +571,7 @@ int SDL_RegisterApp(char *name, Uint32 style, HMODULE hInst)
class.lpszClassName = name; class.lpszClassName = name;
#endif /* _WIN32_WCE */ #endif /* _WIN32_WCE */
class.hbrBackground = NULL; class.hbrBackground = NULL;
class.hInstance = hInst ? hInst : GetModuleHandle(0); class.hInstance = hInst;
class.style = style; class.style = style;
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
class.style |= CS_OWNDC; class.style |= CS_OWNDC;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment