src/video/windib/SDL_dibevents.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 17 Apr 2005 10:23:58 +0000
changeset 1048 a78acdd4967e
parent 975 add87cc1de0a
child 1152 51a8702d8ecd
permissions -rw-r--r--
Fixed direction key input on WinCE devices, thanks to
cal-at-splitreflection-com.

http://www.libsdl.org/pipermail/sdl/2005-April/068072.html
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@769
     3
    Copyright (C) 1997-2004 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
#include <stdlib.h>
slouken@0
    29
#include <stdio.h>
slouken@0
    30
#include <windows.h>
slouken@0
    31
slouken@0
    32
#include "SDL_events.h"
slouken@0
    33
#include "SDL_error.h"
slouken@0
    34
#include "SDL_syswm.h"
slouken@0
    35
#include "SDL_sysevents.h"
slouken@0
    36
#include "SDL_events_c.h"
slouken@0
    37
#include "SDL_lowvideo.h"
slouken@0
    38
#include "SDL_dibvideo.h"
slouken@0
    39
#include "SDL_vkeys.h"
slouken@0
    40
slouken@0
    41
#ifndef WM_APP
slouken@0
    42
#define WM_APP	0x8000
slouken@0
    43
#endif
slouken@0
    44
slouken@0
    45
#ifdef _WIN32_WCE
slouken@0
    46
#define NO_GETKEYBOARDSTATE
slouken@0
    47
#endif
slouken@0
    48
slouken@0
    49
/* The translation table from a Microsoft VK keysym to a SDL keysym */
slouken@0
    50
static SDLKey VK_keymap[SDLK_LAST];
slouken@0
    51
static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed);
slouken@572
    52
static BOOL prev_shiftstates[2];
slouken@0
    53
slouken@0
    54
/* Masks for processing the windows KEYDOWN and KEYUP messages */
slouken@0
    55
#define REPEATED_KEYMASK	(1<<30)
slouken@0
    56
#define EXTENDED_KEYMASK	(1<<24)
slouken@0
    57
slouken@145
    58
/* DJM: If the user setup the window for us, we want to save his window proc,
slouken@145
    59
   and give him a chance to handle some messages. */
slouken@145
    60
static WNDPROC userWindowProc = NULL;
slouken@145
    61
slouken@0
    62
/* The main Win32 event handler */
slouken@0
    63
LONG
slouken@0
    64
 DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
slouken@0
    65
{
slouken@0
    66
	extern int posted;
slouken@0
    67
slouken@0
    68
	switch (msg) {
slouken@0
    69
		case WM_SYSKEYDOWN:
slouken@0
    70
		case WM_KEYDOWN: {
slouken@0
    71
			SDL_keysym keysym;
slouken@0
    72
slouken@0
    73
			/* Ignore repeated keys */
slouken@0
    74
			if ( lParam&REPEATED_KEYMASK ) {
slouken@0
    75
				return(0);
slouken@0
    76
			}
slouken@0
    77
			switch (wParam) {
slouken@0
    78
				case VK_CONTROL:
slouken@0
    79
					if ( lParam&EXTENDED_KEYMASK )
slouken@0
    80
						wParam = VK_RCONTROL;
slouken@0
    81
					else
slouken@0
    82
						wParam = VK_LCONTROL;
slouken@0
    83
					break;
slouken@0
    84
				case VK_SHIFT:
slouken@0
    85
					/* EXTENDED trick doesn't work here */
slouken@572
    86
					if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) {
slouken@558
    87
						wParam = VK_LSHIFT;
slouken@572
    88
						prev_shiftstates[0] = TRUE;
slouken@572
    89
					} else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) {
slouken@558
    90
						wParam = VK_RSHIFT;
slouken@572
    91
						prev_shiftstates[1] = TRUE;
slouken@558
    92
					} else {
slouken@558
    93
						/* Huh? */
slouken@558
    94
					}
slouken@0
    95
					break;
slouken@0
    96
				case VK_MENU:
slouken@0
    97
					if ( lParam&EXTENDED_KEYMASK )
slouken@0
    98
						wParam = VK_RMENU;
slouken@0
    99
					else
slouken@0
   100
						wParam = VK_LMENU;
slouken@0
   101
					break;
slouken@0
   102
			}
slouken@112
   103
#ifdef NO_GETKEYBOARDSTATE
slouken@112
   104
			/* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
slouken@112
   105
			if ( SDL_TranslateUNICODE ) {
slouken@140
   106
				MSG m;
slouken@112
   107
slouken@140
   108
				m.hwnd = hwnd;
slouken@140
   109
				m.message = msg;
slouken@140
   110
				m.wParam = wParam;
slouken@140
   111
				m.lParam = lParam;
slouken@140
   112
				m.time = 0;
slouken@140
   113
				if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
slouken@112
   114
					GetMessage(&m, hwnd, 0, WM_USER);
slouken@112
   115
			    		wParam = m.wParam;
slouken@112
   116
				} else {
slouken@112
   117
					wParam = 0;
slouken@112
   118
				}
slouken@112
   119
			}
slouken@112
   120
#endif /* NO_GETKEYBOARDSTATE */
slouken@0
   121
			posted = SDL_PrivateKeyboard(SDL_PRESSED,
slouken@0
   122
				TranslateKey(wParam,HIWORD(lParam),&keysym,1));
slouken@0
   123
		}
slouken@0
   124
		return(0);
slouken@0
   125
slouken@0
   126
		case WM_SYSKEYUP:
slouken@0
   127
		case WM_KEYUP: {
slouken@0
   128
			SDL_keysym keysym;
slouken@0
   129
slouken@0
   130
			switch (wParam) {
slouken@0
   131
				case VK_CONTROL:
slouken@0
   132
					if ( lParam&EXTENDED_KEYMASK )
slouken@0
   133
						wParam = VK_RCONTROL;
slouken@0
   134
					else
slouken@0
   135
						wParam = VK_LCONTROL;
slouken@0
   136
					break;
slouken@0
   137
				case VK_SHIFT:
slouken@0
   138
					/* EXTENDED trick doesn't work here */
slouken@572
   139
					if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
slouken@572
   140
						wParam = VK_LSHIFT;
slouken@572
   141
						prev_shiftstates[0] = FALSE;
slouken@572
   142
					} else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
slouken@572
   143
						wParam = VK_RSHIFT;
slouken@572
   144
						prev_shiftstates[1] = FALSE;
slouken@572
   145
					} else {
slouken@572
   146
						/* Huh? */
slouken@572
   147
					}
slouken@0
   148
					break;
slouken@0
   149
				case VK_MENU:
slouken@0
   150
					if ( lParam&EXTENDED_KEYMASK )
slouken@0
   151
						wParam = VK_RMENU;
slouken@0
   152
					else
slouken@0
   153
						wParam = VK_LMENU;
slouken@0
   154
					break;
slouken@0
   155
			}
slouken@0
   156
			posted = SDL_PrivateKeyboard(SDL_RELEASED,
slouken@0
   157
				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
slouken@0
   158
		}
slouken@0
   159
		return(0);
slouken@0
   160
icculus@726
   161
#if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
icculus@726
   162
		case WM_SYSCOMMAND: {
icculus@726
   163
			if ((wParam&0xFFF0)==SC_SCREENSAVE ||
icculus@726
   164
				(wParam&0xFFF0)==SC_MONITORPOWER)
icculus@726
   165
					return(0);
icculus@726
   166
		}
icculus@726
   167
		/* Fall through to default processing */
icculus@726
   168
#endif /* SC_SCREENSAVE && SC_MONITORPOWER */
icculus@726
   169
slouken@0
   170
		default: {
slouken@0
   171
			/* Only post the event if we're watching for it */
slouken@0
   172
			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
slouken@0
   173
			        SDL_SysWMmsg wmmsg;
slouken@0
   174
slouken@0
   175
				SDL_VERSION(&wmmsg.version);
slouken@0
   176
				wmmsg.hwnd = hwnd;
slouken@0
   177
				wmmsg.msg = msg;
slouken@0
   178
				wmmsg.wParam = wParam;
slouken@0
   179
				wmmsg.lParam = lParam;
slouken@0
   180
				posted = SDL_PrivateSysWMEvent(&wmmsg);
slouken@145
   181
slouken@145
   182
			/* DJM: If the user isn't watching for private
slouken@145
   183
				messages in her SDL event loop, then pass it
slouken@145
   184
				along to any win32 specific window proc.
slouken@145
   185
			 */
slouken@145
   186
			} else if (userWindowProc) {
slouken@721
   187
				return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam);
slouken@0
   188
			}
slouken@0
   189
		}
slouken@0
   190
		break;
slouken@0
   191
	}
slouken@0
   192
	return(DefWindowProc(hwnd, msg, wParam, lParam));
slouken@0
   193
}
slouken@0
   194
slouken@0
   195
void DIB_PumpEvents(_THIS)
slouken@0
   196
{
slouken@0
   197
	MSG msg;
slouken@0
   198
slouken@523
   199
	while ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
slouken@523
   200
		if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
slouken@0
   201
			DispatchMessage(&msg);
slouken@0
   202
		}
slouken@0
   203
	}
slouken@0
   204
}
slouken@0
   205
slouken@0
   206
void DIB_InitOSKeymap(_THIS)
slouken@0
   207
{
slouken@0
   208
	int i;
slouken@0
   209
slouken@0
   210
	/* Map the VK keysyms */
slouken@0
   211
	for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i )
slouken@0
   212
		VK_keymap[i] = SDLK_UNKNOWN;
slouken@0
   213
slouken@0
   214
	VK_keymap[VK_BACK] = SDLK_BACKSPACE;
slouken@0
   215
	VK_keymap[VK_TAB] = SDLK_TAB;
slouken@0
   216
	VK_keymap[VK_CLEAR] = SDLK_CLEAR;
slouken@0
   217
	VK_keymap[VK_RETURN] = SDLK_RETURN;
slouken@0
   218
	VK_keymap[VK_PAUSE] = SDLK_PAUSE;
slouken@0
   219
	VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
slouken@0
   220
	VK_keymap[VK_SPACE] = SDLK_SPACE;
slouken@0
   221
	VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
slouken@0
   222
	VK_keymap[VK_COMMA] = SDLK_COMMA;
slouken@0
   223
	VK_keymap[VK_MINUS] = SDLK_MINUS;
slouken@0
   224
	VK_keymap[VK_PERIOD] = SDLK_PERIOD;
slouken@0
   225
	VK_keymap[VK_SLASH] = SDLK_SLASH;
slouken@0
   226
	VK_keymap[VK_0] = SDLK_0;
slouken@0
   227
	VK_keymap[VK_1] = SDLK_1;
slouken@0
   228
	VK_keymap[VK_2] = SDLK_2;
slouken@0
   229
	VK_keymap[VK_3] = SDLK_3;
slouken@0
   230
	VK_keymap[VK_4] = SDLK_4;
slouken@0
   231
	VK_keymap[VK_5] = SDLK_5;
slouken@0
   232
	VK_keymap[VK_6] = SDLK_6;
slouken@0
   233
	VK_keymap[VK_7] = SDLK_7;
slouken@0
   234
	VK_keymap[VK_8] = SDLK_8;
slouken@0
   235
	VK_keymap[VK_9] = SDLK_9;
slouken@0
   236
	VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
slouken@0
   237
	VK_keymap[VK_EQUALS] = SDLK_EQUALS;
slouken@0
   238
	VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
slouken@0
   239
	VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
slouken@0
   240
	VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
slouken@0
   241
	VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
slouken@327
   242
	VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
slouken@0
   243
	VK_keymap[VK_A] = SDLK_a;
slouken@0
   244
	VK_keymap[VK_B] = SDLK_b;
slouken@0
   245
	VK_keymap[VK_C] = SDLK_c;
slouken@0
   246
	VK_keymap[VK_D] = SDLK_d;
slouken@0
   247
	VK_keymap[VK_E] = SDLK_e;
slouken@0
   248
	VK_keymap[VK_F] = SDLK_f;
slouken@0
   249
	VK_keymap[VK_G] = SDLK_g;
slouken@0
   250
	VK_keymap[VK_H] = SDLK_h;
slouken@0
   251
	VK_keymap[VK_I] = SDLK_i;
slouken@0
   252
	VK_keymap[VK_J] = SDLK_j;
slouken@0
   253
	VK_keymap[VK_K] = SDLK_k;
slouken@0
   254
	VK_keymap[VK_L] = SDLK_l;
slouken@0
   255
	VK_keymap[VK_M] = SDLK_m;
slouken@0
   256
	VK_keymap[VK_N] = SDLK_n;
slouken@0
   257
	VK_keymap[VK_O] = SDLK_o;
slouken@0
   258
	VK_keymap[VK_P] = SDLK_p;
slouken@0
   259
	VK_keymap[VK_Q] = SDLK_q;
slouken@0
   260
	VK_keymap[VK_R] = SDLK_r;
slouken@0
   261
	VK_keymap[VK_S] = SDLK_s;
slouken@0
   262
	VK_keymap[VK_T] = SDLK_t;
slouken@0
   263
	VK_keymap[VK_U] = SDLK_u;
slouken@0
   264
	VK_keymap[VK_V] = SDLK_v;
slouken@0
   265
	VK_keymap[VK_W] = SDLK_w;
slouken@0
   266
	VK_keymap[VK_X] = SDLK_x;
slouken@0
   267
	VK_keymap[VK_Y] = SDLK_y;
slouken@0
   268
	VK_keymap[VK_Z] = SDLK_z;
slouken@0
   269
	VK_keymap[VK_DELETE] = SDLK_DELETE;
slouken@0
   270
slouken@0
   271
	VK_keymap[VK_NUMPAD0] = SDLK_KP0;
slouken@0
   272
	VK_keymap[VK_NUMPAD1] = SDLK_KP1;
slouken@0
   273
	VK_keymap[VK_NUMPAD2] = SDLK_KP2;
slouken@0
   274
	VK_keymap[VK_NUMPAD3] = SDLK_KP3;
slouken@0
   275
	VK_keymap[VK_NUMPAD4] = SDLK_KP4;
slouken@0
   276
	VK_keymap[VK_NUMPAD5] = SDLK_KP5;
slouken@0
   277
	VK_keymap[VK_NUMPAD6] = SDLK_KP6;
slouken@0
   278
	VK_keymap[VK_NUMPAD7] = SDLK_KP7;
slouken@0
   279
	VK_keymap[VK_NUMPAD8] = SDLK_KP8;
slouken@0
   280
	VK_keymap[VK_NUMPAD9] = SDLK_KP9;
slouken@0
   281
	VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
slouken@0
   282
	VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
slouken@0
   283
	VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
slouken@0
   284
	VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
slouken@0
   285
	VK_keymap[VK_ADD] = SDLK_KP_PLUS;
slouken@0
   286
slouken@0
   287
	VK_keymap[VK_UP] = SDLK_UP;
slouken@0
   288
	VK_keymap[VK_DOWN] = SDLK_DOWN;
slouken@0
   289
	VK_keymap[VK_RIGHT] = SDLK_RIGHT;
slouken@0
   290
	VK_keymap[VK_LEFT] = SDLK_LEFT;
slouken@0
   291
	VK_keymap[VK_INSERT] = SDLK_INSERT;
slouken@0
   292
	VK_keymap[VK_HOME] = SDLK_HOME;
slouken@0
   293
	VK_keymap[VK_END] = SDLK_END;
slouken@0
   294
	VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
slouken@0
   295
	VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
slouken@0
   296
slouken@0
   297
	VK_keymap[VK_F1] = SDLK_F1;
slouken@0
   298
	VK_keymap[VK_F2] = SDLK_F2;
slouken@0
   299
	VK_keymap[VK_F3] = SDLK_F3;
slouken@0
   300
	VK_keymap[VK_F4] = SDLK_F4;
slouken@0
   301
	VK_keymap[VK_F5] = SDLK_F5;
slouken@0
   302
	VK_keymap[VK_F6] = SDLK_F6;
slouken@0
   303
	VK_keymap[VK_F7] = SDLK_F7;
slouken@0
   304
	VK_keymap[VK_F8] = SDLK_F8;
slouken@0
   305
	VK_keymap[VK_F9] = SDLK_F9;
slouken@0
   306
	VK_keymap[VK_F10] = SDLK_F10;
slouken@0
   307
	VK_keymap[VK_F11] = SDLK_F11;
slouken@0
   308
	VK_keymap[VK_F12] = SDLK_F12;
slouken@0
   309
	VK_keymap[VK_F13] = SDLK_F13;
slouken@0
   310
	VK_keymap[VK_F14] = SDLK_F14;
slouken@0
   311
	VK_keymap[VK_F15] = SDLK_F15;
slouken@0
   312
slouken@0
   313
	VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
slouken@0
   314
	VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
slouken@0
   315
	VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
slouken@0
   316
	VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
slouken@0
   317
	VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
slouken@0
   318
	VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
slouken@0
   319
	VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
slouken@0
   320
	VK_keymap[VK_RMENU] = SDLK_RALT;
slouken@0
   321
	VK_keymap[VK_LMENU] = SDLK_LALT;
slouken@0
   322
	VK_keymap[VK_RWIN] = SDLK_RSUPER;
slouken@0
   323
	VK_keymap[VK_LWIN] = SDLK_LSUPER;
slouken@0
   324
slouken@0
   325
	VK_keymap[VK_HELP] = SDLK_HELP;
slouken@0
   326
#ifdef VK_PRINT
slouken@0
   327
	VK_keymap[VK_PRINT] = SDLK_PRINT;
slouken@0
   328
#endif
slouken@0
   329
	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
slouken@0
   330
	VK_keymap[VK_CANCEL] = SDLK_BREAK;
slouken@0
   331
	VK_keymap[VK_APPS] = SDLK_MENU;
slouken@572
   332
slouken@572
   333
	prev_shiftstates[0] = FALSE;
slouken@572
   334
	prev_shiftstates[1] = FALSE;
slouken@0
   335
}
slouken@0
   336
slouken@0
   337
static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
slouken@0
   338
{
slouken@0
   339
	/* Set the keysym information */
slouken@0
   340
	keysym->scancode = (unsigned char) scancode;
slouken@0
   341
	keysym->sym = VK_keymap[vkey];
slouken@0
   342
	keysym->mod = KMOD_NONE;
slouken@0
   343
	keysym->unicode = 0;
slouken@0
   344
	if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
slouken@0
   345
#ifdef NO_GETKEYBOARDSTATE
slouken@0
   346
		/* Uh oh, better hope the vkey is close enough.. */
slouken@0
   347
		keysym->unicode = vkey;
slouken@0
   348
#else
slouken@0
   349
		BYTE keystate[256];
slouken@0
   350
		BYTE chars[2];
slouken@0
   351
slouken@0
   352
		GetKeyboardState(keystate);
slouken@0
   353
		if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
slouken@0
   354
			keysym->unicode = chars[0];
slouken@0
   355
		}
slouken@0
   356
#endif /* NO_GETKEYBOARDSTATE */
slouken@0
   357
	}
slouken@0
   358
	return(keysym);
slouken@0
   359
}
slouken@0
   360
slouken@0
   361
int DIB_CreateWindow(_THIS)
slouken@0
   362
{
slouken@453
   363
#ifndef CS_BYTEALIGNCLIENT
slouken@453
   364
#define CS_BYTEALIGNCLIENT	0
slouken@453
   365
#endif
slouken@0
   366
	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
slouken@0
   367
	if ( SDL_windowid ) {
slouken@0
   368
		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
slouken@974
   369
		if ( SDL_Window == NULL ) {
slouken@974
   370
			SDL_SetError("Couldn't get user specified window");
slouken@974
   371
			return(-1);
slouken@974
   372
		}
slouken@974
   373
slouken@974
   374
		/* DJM: we want all event's for the user specified
slouken@974
   375
			window to be handled by SDL.
slouken@974
   376
		 */
slouken@974
   377
		userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
slouken@974
   378
		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
slouken@0
   379
	} else {
slouken@0
   380
		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
slouken@0
   381
                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
slouken@833
   382
                        CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
slouken@0
   383
		if ( SDL_Window == NULL ) {
slouken@0
   384
			SDL_SetError("Couldn't create window");
slouken@0
   385
			return(-1);
slouken@0
   386
		}
slouken@0
   387
		ShowWindow(SDL_Window, SW_HIDE);
slouken@0
   388
	}
slouken@0
   389
	return(0);
slouken@0
   390
}
slouken@0
   391
slouken@0
   392
void DIB_DestroyWindow(_THIS)
slouken@0
   393
{
slouken@974
   394
	if ( SDL_windowid ) {
slouken@974
   395
		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc);
slouken@974
   396
	} else {
slouken@0
   397
		DestroyWindow(SDL_Window);
slouken@0
   398
	}
slouken@0
   399
}