src/video/wincommon/SDL_sysevents.c
changeset 1288 ea3888b472bf
parent 1287 15a89a0c52bf
child 1290 c4a5a772c5d9
     1.1 --- a/src/video/wincommon/SDL_sysevents.c	Sun Jan 29 08:50:06 2006 +0000
     1.2 +++ b/src/video/wincommon/SDL_sysevents.c	Sun Jan 29 09:13:36 2006 +0000
     1.3 @@ -58,6 +58,7 @@
     1.4  #else
     1.5  LPSTR SDL_Appname = NULL;
     1.6  #endif
     1.7 +Uint32 SDL_Appstyle = 0;
     1.8  HINSTANCE SDL_Instance = NULL;
     1.9  HWND SDL_Window = NULL;
    1.10  RECT SDL_bounds = {0, 0, 0, 0};
    1.11 @@ -693,36 +694,40 @@
    1.12  		return(0);
    1.13  	}
    1.14  
    1.15 -	/* This function needs to be passed the correct process handle
    1.16 -	   by the application.
    1.17 -	 */
    1.18 -	if ( ! hInst ) {
    1.19 -		hInst = SDL_GetModuleHandle();
    1.20 +#ifndef CS_BYTEALIGNCLIENT
    1.21 +#define CS_BYTEALIGNCLIENT	0
    1.22 +#endif
    1.23 +	if ( ! name && ! SDL_Appname ) {
    1.24 +		name = "SDL_app";
    1.25 +		SDL_Appstyle = CS_BYTEALIGNCLIENT;
    1.26 +		SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
    1.27 +	}
    1.28 +
    1.29 +	if ( name ) {
    1.30 +#ifdef _WIN32_WCE
    1.31 +		/* WinCE uses the UNICODE version */
    1.32 +		int nLen = strlen(name)+1;
    1.33 +		SDL_Appname = malloc(nLen*2);
    1.34 +		MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
    1.35 +#else
    1.36 +		int nLen = strlen(name)+1;
    1.37 +		SDL_Appname = malloc(nLen);
    1.38 +		strcpy(SDL_Appname, name);
    1.39 +#endif /* _WIN32_WCE */
    1.40 +		SDL_Appstyle = style;
    1.41 +		SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
    1.42  	}
    1.43  
    1.44  	/* Register the application class */
    1.45  	class.hCursor		= NULL;
    1.46 -#ifdef _WIN32_WCE
    1.47 -	{
    1.48 -		/* WinCE uses the UNICODE version */
    1.49 -		int nLen = strlen(name)+1;
    1.50 -		SDL_Appname = malloc(nLen*2);
    1.51 -		MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
    1.52 -	}
    1.53 -#else
    1.54 -	{
    1.55 -		int nLen = strlen(name)+1;
    1.56 -		SDL_Appname = malloc(nLen);
    1.57 -		strcpy(SDL_Appname, name);
    1.58 -	}
    1.59 -#endif /* _WIN32_WCE */
    1.60 -	class.hIcon		= LoadImage(hInst, SDL_Appname, IMAGE_ICON,
    1.61 +	class.hIcon		= LoadImage(SDL_Instance, SDL_Appname,
    1.62 +				            IMAGE_ICON,
    1.63  	                                    0, 0, LR_DEFAULTCOLOR);
    1.64  	class.lpszMenuName	= NULL;
    1.65  	class.lpszClassName	= SDL_Appname;
    1.66  	class.hbrBackground	= NULL;
    1.67 -	class.hInstance		= hInst;
    1.68 -	class.style		= style;
    1.69 +	class.hInstance		= SDL_Instance;
    1.70 +	class.style		= SDL_Appstyle;
    1.71  #ifdef HAVE_OPENGL
    1.72  	class.style		|= CS_OWNDC;
    1.73  #endif
    1.74 @@ -733,7 +738,6 @@
    1.75  		SDL_SetError("Couldn't register application class");
    1.76  		return(-1);
    1.77  	}
    1.78 -	SDL_Instance = hInst;
    1.79  
    1.80  #ifdef WM_MOUSELEAVE
    1.81  	/* Get the version of TrackMouseEvent() we use */
    1.82 @@ -757,23 +761,19 @@
    1.83  	return(0);
    1.84  }
    1.85  
    1.86 -/*
    1.87 - * Unregisters the windowclass registered in SDL_RegisterApp above.
    1.88 - *  Called from DIB_VideoQuit and DX5_VideoQuit when
    1.89 - *  SDL_QuitSubSystem(INIT_VIDEO) is called.
    1.90 - */
    1.91 +/* Unregisters the windowclass registered in SDL_RegisterApp above. */
    1.92  void SDL_UnregisterApp()
    1.93  {
    1.94  	WNDCLASS class;
    1.95  
    1.96  	/* SDL_RegisterApp might not have been called before */
    1.97 -	if (app_registered) {
    1.98 -		/* Check for any registered windowclasses. */
    1.99 -		if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) {
   1.100 +	if ( app_registered ) {
   1.101 +		/* Check for any registered window classes. */
   1.102 +		if ( GetClassInfo(SDL_Instance, SDL_Appname, &class) ) {
   1.103  			UnregisterClass(SDL_Appname, SDL_Instance);
   1.104  		}
   1.105 +		app_registered = 0;
   1.106  	}
   1.107 -	app_registered = 0;
   1.108  }
   1.109  
   1.110  #ifndef NO_GETKEYBOARDSTATE