src/video/win32/SDL_win32window.c
branchgsoc2008_force_feedback
changeset 2584 e8644f625d45
parent 2583 2ae5b4fc6af5
child 2585 38f14c05a92c
equal deleted inserted replaced
2583:2ae5b4fc6af5 2584:e8644f625d45
    30 #include "SDL_syswm.h"
    30 #include "SDL_syswm.h"
    31 
    31 
    32 
    32 
    33 /* Fake window to help with DirectInput events. */
    33 /* Fake window to help with DirectInput events. */
    34 HWND SDL_HelperWindow = NULL;
    34 HWND SDL_HelperWindow = NULL;
       
    35 static ATOM SDL_HelperWindowClass = 0;
    35 
    36 
    36 
    37 
    37 static int
    38 static int
    38 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
    39 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
    39 {
    40 {
   423    HINSTANCE hInstance = GetModuleHandleA(NULL);
   424    HINSTANCE hInstance = GetModuleHandleA(NULL);
   424    const char *class_name = "SDLHelperWindowInputCatcher";
   425    const char *class_name = "SDLHelperWindowInputCatcher";
   425    const char *win_name = "SDLHelperWindowInputMsgWindow";
   426    const char *win_name = "SDLHelperWindowInputMsgWindow";
   426    WNDCLASSEX wce;
   427    WNDCLASSEX wce;
   427 
   428 
       
   429    /* Create the class. */
   428    ZeroMemory(&wce, sizeof (wce));
   430    ZeroMemory(&wce, sizeof (wce));
   429    wce.cbSize = sizeof(WNDCLASSEX);
   431    wce.cbSize = sizeof(WNDCLASSEX);
   430    wce.lpfnWndProc = NULL;
   432    wce.lpfnWndProc = NULL;
   431    wce.lpszClassName = (LPCWSTR) class_name;
   433    wce.lpszClassName = (LPCWSTR) class_name;
   432    wce.hInstance = hInstance;
   434    wce.hInstance = hInstance;
   433 
   435 
       
   436    /* Register the class. */
       
   437    SDL_HelperWindowClass = RegisterClassExA(&wce);
       
   438    if (SDL_HelperWindowClass == 0) {
       
   439       SDL_SetError("Unable to create Helper Window Class: error %d.", GetLastError());
       
   440       return -1;
       
   441    }
       
   442 
       
   443    /* Create the window. */
   434    SDL_HelperWindow = CreateWindowExA(0, class_name, win_name, WS_OVERLAPPEDWINDOW,
   444    SDL_HelperWindow = CreateWindowExA(0, class_name, win_name, WS_OVERLAPPEDWINDOW,
   435          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
   445          CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
   436          CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL);
   446          CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL);
   437 
       
   438    if (SDL_HelperWindow == NULL) {
   447    if (SDL_HelperWindow == NULL) {
   439       SDL_SetError("Unable to create Helper Window: error %d.", GetLastError());
   448       SDL_SetError("Unable to create Helper Window: error %d.", GetLastError());
   440       return -1;
   449       return -1;
   441    }
   450    }
   442 
   451 
   448  * Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
   457  * Destroys the HelperWindow previously created with SDL_HelperWindowCreate.
   449  */
   458  */
   450 void
   459 void
   451 SDL_HelperWindowDestroy(void)
   460 SDL_HelperWindowDestroy(void)
   452 {
   461 {
       
   462    /* Destroy the window. */
   453    if (SDL_HelperWindow) {
   463    if (SDL_HelperWindow) {
   454       DestroyWindow(SDL_HelperWindow);
   464       DestroyWindow(SDL_HelperWindow);
   455       SDL_HelperWindow = NULL;
   465       SDL_HelperWindow = NULL;
   456    }
   466    }
       
   467 
       
   468    /* Unregister the class. */
       
   469    if (SDL_HelperWindowClass) {
       
   470       UnregisterClassA(SDL_HelperWindowClass, GetModuleHandleA(NULL));
       
   471       SDL_HelperWindowClass = 0;
       
   472    }
   457 }
   473 }
   458 
   474 
   459 
   475 
   460 /* vi: set ts=4 sw=4 expandtab: */
   476 /* vi: set ts=4 sw=4 expandtab: */