Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Seems like you have to register the class and other black magic too.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Aug 4, 2008
1 parent 38410de commit 4c95595
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/video/win32/SDL_win32window.c
Expand Up @@ -32,6 +32,7 @@

/* Fake window to help with DirectInput events. */
HWND SDL_HelperWindow = NULL;
static ATOM SDL_HelperWindowClass = 0;


static int
Expand Down Expand Up @@ -425,16 +426,24 @@ SDL_HelperWindowCreate(void)
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;
Expand All @@ -450,10 +459,17 @@ SDL_HelperWindowCreate(void)
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;
}
}


Expand Down

0 comments on commit 4c95595

Please sign in to comment.