Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SetThreadUILanguage on Windows XP vs. Vista+?

The docs for SetThreadUILanguage state that:

Windows XP: The application can only set this parameter to 0. This setting causes the function to select the language that best supports the console display. For more information, see the Remarks section.

It later goes on (rather hidden in the middle of a paragraph):

(...) Windows XP does not support a concept of thread user interface language separate from thread locale. Therefore, this function changes the thread locale on Windows XP. (...)

And this in fact seems to be what happens, that is, calling SetThreadUILanguage on Windows XP seems to amount to calling SetThreadLocale, while on Vista+ it seems to result in basically the same thing as calling SetThreadPreferredUILanguages (which isn't available on XP at all).

The docs are clear as mud to me, so my basic question probably is: Am I supposed to call SetThreadUILanguage on Windows XP to change the (preferred) UI langauge and is this properly documented somewhere, and on Windows 7, am I supposed to call this function at all, or should I call SetThreadPreferredUILanguages?

like image 472
Martin Ba Avatar asked Oct 04 '22 06:10

Martin Ba


1 Answers

I know it's an old thread, but I'm curious if you found a solution? I'm dealing with the same issue and I'm totally perplexed by Microsoft's documentation. Here's what I learned so far:

1 SetThreadLocale is pretty much useless. I am not really sure what the heck it does. MSDN page here first states this:

SetThreadLocale affects the selection of resources with a LANGUAGE statement. The statement affects such functions as CreateDialog, DialogBox, LoadMenu, LoadString, and FindResource. It sets the code page implied by CP_THREAD_ACP, but does not affect FindResourceEx.

OK. I get this part. But then it has this "gem":

Windows Vista and later: Do not use SetThreadLocale to select a user interface language.

Now it's pure Microsoft :) So what the heck was all that hogwash in the paragraph above?

2 SetThreadUILanguage works only on Vista and later OS. On XP it does pretty much nothing, so unless you want to miss out on a large number of users that still stick with XP, this API is also useless for now. (It seems to do the job all by itself on Vista and later OS though.)

3 SetThreadPreferredUILanguages works on Vista and later OS only, so we're going back to the lack of XP support. From what I understand, if you include a bunch of languages in resources, say these three: US-English, French, German. When the resource loader loads it, say, in Switzerland a moronic Microsoft loader will pick US-English by default. So this API tells it what language to use. (I know, completely redundant, but, hey, remember, we're dealing with Microsoft.)

The issue that I can't seem to resolve is how to define UI language in XP. It is possible to use FindResourceEx for strings and dialogs (use CreateDialogIndirect), but what about file open/save dialogs or GetOpenFileName and property sheets or CPropertySheet?

So I'm curious how did you handle it?

like image 86
c00000fd Avatar answered Oct 13 '22 12:10

c00000fd