Seems like you have to register the class and other black magic too. gsoc2008_force_feedback
authorEdgar Simo <bobbens@gmail.com>
Mon, 04 Aug 2008 15:17:52 +0000
branchgsoc2008_force_feedback
changeset 2584 e8644f625d45
parent 2583 2ae5b4fc6af5
child 2585 38f14c05a92c
Seems like you have to register the class and other black magic too.
src/video/win32/SDL_win32window.c
--- a/src/video/win32/SDL_win32window.c	Mon Aug 04 14:44:21 2008 +0000
+++ b/src/video/win32/SDL_win32window.c	Mon Aug 04 15:17:52 2008 +0000
@@ -32,6 +32,7 @@
 
 /* Fake window to help with DirectInput events. */
 HWND SDL_HelperWindow = NULL;
+static ATOM SDL_HelperWindowClass = 0;
 
 
 static int
@@ -425,16 +426,24 @@
    const char *win_name = "SDLHelperWindowInputMsgWindow";
    WNDCLASSEX wce;
 
+   /* Create the class. */
    ZeroMemory(&wce, sizeof (wce));
    wce.cbSize = sizeof(WNDCLASSEX);
    wce.lpfnWndProc = NULL;
    wce.lpszClassName = (LPCWSTR) class_name;
    wce.hInstance = hInstance;
 
+   /* Register the class. */
+   SDL_HelperWindowClass = RegisterClassExA(&wce);
+   if (SDL_HelperWindowClass == 0) {
+      SDL_SetError("Unable to create Helper Window Class: error %d.", GetLastError());
+      return -1;
+   }
+
+   /* Create the window. */
    SDL_HelperWindow = CreateWindowExA(0, class_name, win_name, WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
          CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL);
-
    if (SDL_HelperWindow == NULL) {
       SDL_SetError("Unable to create Helper Window: error %d.", GetLastError());
       return -1;
@@ -450,10 +459,17 @@
 void
 SDL_HelperWindowDestroy(void)
 {
+   /* Destroy the window. */
    if (SDL_HelperWindow) {
       DestroyWindow(SDL_HelperWindow);
       SDL_HelperWindow = NULL;
    }
+
+   /* Unregister the class. */
+   if (SDL_HelperWindowClass) {
+      UnregisterClassA(SDL_HelperWindowClass, GetModuleHandleA(NULL));
+      SDL_HelperWindowClass = 0;
+   }
 }