Fixed window titles on Windows 95/98/ME SDL-1.2
authorSam Lantinga
Mon, 23 Jul 2007 01:19:56 +0000
branchSDL-1.2
changeset 4088cbe2f23a1c2b
parent 4087 4867f7f7dd34
child 4089 37345dc3dd83
Fixed window titles on Windows 95/98/ME
src/video/wincommon/SDL_syswm.c
     1.1 --- a/src/video/wincommon/SDL_syswm.c	Fri Jul 20 08:17:45 2007 +0000
     1.2 +++ b/src/video/wincommon/SDL_syswm.c	Mon Jul 23 01:19:56 2007 +0000
     1.3 @@ -217,36 +217,12 @@
     1.4  	SetWindowText(SDL_Window, lpszW);
     1.5  	SDL_free(lpszW);
     1.6  #else
     1.7 -	/*
     1.8 -	 * Try loading SetWindowTextW from kernel32.dll first, and if it exists,
     1.9 -	 *  pass the UCS-2 string to it. If it doesn't, use
    1.10 -	 *  WideCharToMultiByte(CP_ACP) and hope that the codepage can support the
    1.11 -	 *  string data in question. This lets us keep binary compatibility with
    1.12 -	 *  Win95/98/ME but still use saner Unicode on NT-based Windows.
    1.13 -	 */
    1.14 -	static int tried_loading = 0;
    1.15 -	static PtrSetWindowTextW swtw = NULL;
    1.16  	Uint16 *lpsz = SDL_iconv_utf8_ucs2(title);
    1.17 -	if (!tried_loading) {
    1.18 -		HMODULE dll = LoadLibrary("user32.dll");
    1.19 -		if (dll != NULL) {
    1.20 -			swtw = (PtrSetWindowTextW) GetProcAddress(dll, "SetWindowTextW");
    1.21 -			if (swtw == NULL) {
    1.22 -				FreeLibrary(dll);
    1.23 -			}
    1.24 -		}
    1.25 -		tried_loading = 1;
    1.26 -	}
    1.27 -
    1.28 -	if (swtw != NULL) {
    1.29 -		swtw(SDL_Window, lpsz);
    1.30 -	} else {
    1.31 -		size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
    1.32 -		char *cvt = SDL_malloc(len + 1);
    1.33 -		WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
    1.34 -		SetWindowText(SDL_Window, cvt);
    1.35 -		SDL_free(cvt);
    1.36 -	}
    1.37 +	size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
    1.38 +	char *cvt = SDL_stack_alloc(char, len + 1);
    1.39 +	WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
    1.40 +	SetWindowText(SDL_Window, cvt);
    1.41 +	SDL_stack_free(cvt);
    1.42  	SDL_free(lpsz);
    1.43  #endif
    1.44  }