changeset 2584:e8644f625d45 gsoc2008_force_feedback

Seems like you have to register the class and other black magic too.
author Edgar Simo <bobbens@gmail.com>
date Mon, 04 Aug 2008 15:17:52 +0000
parents 2ae5b4fc6af5
children 38f14c05a92c
files src/video/win32/SDL_win32window.c
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
+   }
 }