Pelles C forum

C language => User contributions => Topic started by: JohnF on May 10, 2016, 08:51:06 am

Title: Last Update for FindFile
Post by: JohnF on May 10, 2016, 08:51:06 am
This is probably the last update of FindFile. Mostly trivial changes but worth doing - I've not updated my web site yet.

Code: [Select]
================================
10th May 2016. Version 3.2 (JF)
================================
Removed ButtEx64W.lib & ButtEx32W.lib and included ButtonEx.c for both the
32bit and 64bit projects.

There is only one .RC file now for both the 32bit and 64bit versions of FindFile.
"FindFileUni.rc"

Added a Mutex so that only one instance of FindFile can be run at any
one time. See wWinMain().

The total bytes listed are summed and displayed in the status bar after
the scan has finished, this can also be used to show the bytes used on a
drive, partition or in a folder.

In many cases used the macro ARRSIZE(s) to pass size of buffer to a
Windows API instead of a hardcoded number.

Ctrl+C in header window for clipboard copy, see SubClassTextBoxProc(). Select
text with mouse then Ctrl+C will copy the text to the clipboard.

Changed SHRecycleBin() (Shell.c) to send folders to the Recycle Bin as
well as files.

A new Dutch translation has been added to the resource strings by
Siekmanski, and Grincheux has done a better French translation.

Two Dialog message boxes always displayed in English - fixed.

Added ToolTip to the WebSite button on the About Dialogbox explaining what
one will find there.

Removed the icon from the Search button.

Left in the LFCR's for 'View Search Results' in header window, the text
looks better.

Added icons from applications on the Context 'Send To' menu strip.

===================================

EDIT: The attachment has been updated with the version on my web site. 19 May 2016

John
Title: Re: Last Update for FindFile
Post by: frankie on May 10, 2016, 09:12:41 am
Hello John,
good job.  :)
But... my OS is in english, language is set to italian and... Findfile starts in german  :o :'(
Maybe it is worth another slight update?  ;)
Title: Re: Last Update for FindFile
Post by: JohnF on May 10, 2016, 09:34:47 am
Hello John,
good job.  :)
But... my OS is in english, language is set to italian and... Findfile starts in german  :o :'(
Maybe it is worth another slight update?  ;)

Hmm, not sure what the cause is, it should just take what the OS gives it. Why you would get German I don't know.

Edit: I don't do anything about the language Frankie, the OS does all the work. It is selecting German strings from the resource - but why?

John

Title: Re: Last Update for FindFile
Post by: TimoVJL on May 10, 2016, 10:06:21 am
Thank's John!

frankie:
What language ID's you get?
Code: [Select]
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

int __cdecl DisplayThreadLocale(void)
{
wchar_t szTmp[512];

LCID lcidt = GetThreadLocale();
LCID lcids = GetSystemDefaultLCID();
LCID lcidu = GetUserDefaultLCID();
wsprintf(szTmp,
L"ThreadLocale  0x%04X\nSystemDefaultLCID  0x%04X\nUserDefaultLCID 0x%04X",
lcidt, lcids, lcidu);
MessageBox(0, szTmp, L"DefaultLCID", MB_OK);
return 0;
}

void __cdecl WinMainCRTStartup(void)
{
DisplayThreadLocale();
ExitProcess(0);
}
Title: Re: Last Update for FindFile
Post by: frankie on May 10, 2016, 11:43:20 am
Hello Timo,
I get Italian LCID=0x410 (see image).
John maybe that if the local is not found the default goes to german and not english as it should do.
I'll make a check as I have time. Cheers.  :)
Title: Re: Last Update for FindFile
Post by: JohnF on May 10, 2016, 12:07:38 pm
John maybe that if the local is not found the default goes to german and not english as it should do.
I'll make a check as I have time. Cheers.  :)

Ok.

As you say it should default to english.

John

Title: Re: Last Update for FindFile
Post by: frankie on May 10, 2016, 01:05:15 pm
John I think that the default language should be english.
Anyway the problem is that when a resource is not found for the current LCID the OS defaults to the lower resource LCI. In our case it is the german, 0x0407, which is less than the british english, 0x0809.
The solution is to define language and sublanguage of all common resource, actually defined respectively as LANG_ENGLISH and SUBLANG_ENGLISH_UK, as neutral: LANG_NEUTRAL and SUBLANG_NEUTRAL, which value is 0x0 for both.
In this way any LCID not found will default to neutral that is in english.
You'll find attached an emended version of resources file "FindFileUni.rc".
You can make tests by setting undefined languages like spanish or italian:
Code: [Select]
int APIENTRY wWinMain(HINSTANCE hinst, HINSTANCE hinstPrev, wchar_t * lpCmdLine, int nCmdShow)
{
/* These calls to SetLanguage() are only for testing purposes.
Normally the Locale is set automatically for your locale by the OS.
For completeness this also needs to be done for the other thread in
Private_FindFile()
    */

SetLanguage(0x040a); // Spanish (Spain)
//SetLanguage(0x0410); // Italian (Italy)
//SetLanguage(0x0809); // English (UK)
//SetLanguage(0x040c); // French
//SetLanguage(0x0407); // German (Standard)
//SetLanguage(0x0416); // Portuguese (Brazil)
//SetLanguage(0x040b); // Finnish
//SetLanguage(0x0419); // Rusian
//SetLanguage(0x0413); // Dutch
Title: Re: Last Update for FindFile
Post by: JohnF on May 10, 2016, 01:18:49 pm
This can't be right, having LANG_NEUTRAL and SUBLANG_NEUTRAL results in not being able to set any other of those languages you have seen in wWinMain()

   //SetLanguage(0x040c); // French
   //SetLanguage(0x0407); // German (Standard)
   //SetLanguage(0x0416); // Portuguese (Brazil)
   //SetLanguage(0x040b); // Finnish
   //SetLanguage(0x0419); // Rusian
   //SetLanguage(0x0413); // Dutch

John
Title: Re: Last Update for FindFile
Post by: frankie on May 10, 2016, 01:27:29 pm
I didn't checked...  :(
Let me check again...
Title: Re: Last Update for FindFile
Post by: JohnF on May 10, 2016, 02:07:49 pm
Frankie can you set english in wWinMain when my original RC file is used?

If so I could make a check for the other languages and set english if none of them is found.

However which to use?

GetThreadLocale();
GetSystemDefaultLCID();
GetUserDefaultLCID();

On my system the ThreadLocale is 'english us' the others are 'english uk'.

John
Title: Re: Last Update for FindFile
Post by: frankie on May 10, 2016, 02:54:42 pm
John,
According to this (https://msdn.microsoft.com/en-us/library/cc194810.aspx) MS doc resource loading should use the value from GetThreadLocale();.
But according the same doc:
Quote
If the FindResource and FindResourceEx functions do not find any resources that match the language ID's primary language, they search for resources tagged as "language-neutral." This language ID is useful for resource elements such as icons or cursors that are identical for all languages. If a bitmap or an icon will differ for some languages, you can define one language-neutral bitmap as the default and specify language IDs for as many other customized bitmaps as required. For example, bidirectional applications might require bitmaps with right-to-left directionality. Because the FindResource and FindResourceEx functions always search for specific language IDs first, they will always find a bitmap tagged with that language ID before they find one tagged as language-neutral. The search algorithm they follow is summarized in the following list:
  • Primary language/sublanguage
  • Primary language
  • Language-neutral
  • English (skipped if primary language is English)
  • Any
It should have worked.

Check for language isn't very elegant anyway, but seems the only one to work:
Code: [Select]
int APIENTRY wWinMain(HINSTANCE hinst, HINSTANCE hinstPrev, wchar_t * lpCmdLine, int nCmdShow)
{
/* These calls to SetLanguage() are only for testing purposes.
Normally the Locale is set automatically for your locale by the OS.
For completeness this also needs to be done for the other thread in
Private_FindFile()
    */

//SetLanguage(0x040a); // Spanish (Spain)
//SetLanguage(0x0410); // Italian (Italy)
//SetLanguage(0x0809); // English (UK)
//SetLanguage(0x040c); // French
//SetLanguage(0x0407); // German (Standard)
//SetLanguage(0x0416); // Portuguese (Brazil)
//SetLanguage(0x040b); // Finnish
//SetLanguage(0x0419); // Rusian
//SetLanguage(0x0413); // Dutch

//Set english as default language for those not supported
switch(GetThreadLocale())
{
case (0x0809): // English (UK)
case (0x040c): // French
case (0x0407): // German (Standard)
case (0x0416): // Portuguese (Brazil)
case (0x040b): // Finnish
case (0x0419): // Rusian
case (0x0413): // Dutch
break;
default:
SetThreadLocale(MAKELCID(0x0809, SORT_DEFAULT));
}

// This needs to be here for the MsgBox() call that requires ButtonEx stuff.
InitButtonEx();
      ....
Title: Re: Last Update for FindFile
Post by: JohnF on May 10, 2016, 03:28:48 pm
Yes not good - thanks for all your help, I've included the check.

I have updated the original attachment.

EDIT: And in case anyone needs to know the check and setting has to be done in wWinMain() and also in another thread - Private_FindFile() which is in Find.c

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 11, 2016, 09:11:29 am
Simplified test project to check how this works :-\
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void SetLanguage(LANGID lid);
void __cdecl WinMainCRTStartup(void)
{
TCHAR szTmp[256];
//SetLanguage(0x0410); // Italian (Italy)
SetLanguage(0x040c); // French
LoadString(GetModuleHandle(NULL), 10001, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
MessageBox(0,szTmp,0,MB_OK);

ExitProcess(0);
}
void SetLanguage(LANGID lid)
{
typedef LANGID (WINAPI *fnPtr) (LANGID wReserved);

if ((GetVersion() & 0x00FF) > 5) {// Vista =>
LANGID lid2;
fnPtr pSetThreadUILanguage  = (fnPtr)GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")), "SetThreadUILanguage");
if (pSetThreadUILanguage)
// lid2 should equal lid
lid2 = (*pSetThreadUILanguage)(lid);
} else {
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
}
}
Code: [Select]
#include <windows.h>
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
STRINGTABLE { 10001, "English US" }
LANGUAGE LANG_GERMAN,SUBLANG_GERMAN
STRINGTABLE { 10001, "German" }
LANGUAGE LANG_FRENCH,SUBLANG_FRENCH
STRINGTABLE { 10001, "French" }
Code: [Select]
#include <windows.h>
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
STRINGTABLE { 10001, "Neutral" }
For Windows 10:
if there is NEUTRAL language, it is chosen
otherwise ENGLISH
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 11:44:52 am
What happens with FindFile if you take out the Finnish strings - also not have Frankie's code that sets English anyway? switch/case stuff.

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 11, 2016, 12:12:35 pm
I see english texts in Windows 10
But German text in English version Windows 7.
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 12:15:25 pm
So Windows 10 behaves as expected.

Frankie, what OS are you using?

John
Title: Re: Last Update for FindFile
Post by: frankie on May 11, 2016, 12:18:51 pm
John I'm using Win7.
In my test I have simply renamed the language english as neutral I have not tried to add the neutral.
I'm busy now, but maybe it is worth a check.
I'll do as soon as I can.
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 12:46:06 pm
I'm leaving in that code you supplied anyway just in case. It's been changed a little so that both in wWinMain() and Private_FindFile() there is a call to IsLanguageSupported() and that is in utils.c.

The latest last ever update is mow on my web site, if anyone is interested.

This is from utils.c

Code: [Select]
// From example Timo put on the PellesC forum.
void SetLanguage(LANGID lid)
{
typedef LANGID (WINAPI *fnPtr) (LANGID wReserved);

if ((GetVersion() & 0x00FF) > 5) // Vista =>
{
LANGID lid2;
fnPtr pSetThreadUILanguage  = (fnPtr)GetProcAddress(
GetModuleHandle(L"kernel32.dll"), "SetThreadUILanguage");

if (pSetThreadUILanguage)
// lid2 should equal lid
lid2 = (*pSetThreadUILanguage)(lid);

}
else
{
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
}
}

void IsLanguageSupported(void)
{
//Set english as default language for those not supported
switch (GetThreadLocale())
{
case (0x0809): // English (UK)
case (0x040c): // French
case (0x0407): // German (Standard)
case (0x0416): // Portuguese (Brazil)
case (0x040b): // Finnish
case (0x0419): // Rusian
case (0x0413): // Dutch
break;
default:
SetLanguage(0x0809);
}

// These calls to SetLanguage() are only for testing purposes.
// Normally the Locale is set automatically for your locale by the OS.

//SetLanguage(0x040a); // Spanish (Spain)
//SetLanguage(0x0410); // Italian (Italy)
//SetLanguage(0x0809); // English (UK)
//SetLanguage(0x040c); // French
//SetLanguage(0x0407); // German (Standard)
//SetLanguage(0x0416); // Portuguese (Brazil)
//SetLanguage(0x040b); // Finnish
//SetLanguage(0x0419); // Rusian
//SetLanguage(0x0413); // Dutch

}

John

Title: Re: Last Update for FindFile
Post by: TimoVJL on May 11, 2016, 01:34:43 pm
frankie was right:
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
before english/default string table correct that problem in Windows 7.
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 02:04:44 pm
frankie was right:
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
before english/default string table correct that problem in Windows 7.

So, without the actual strings - like this it works.

Code: [Select]
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK

STRINGTABLE
{
  1, "Explore Folder"

John
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 02:11:05 pm
And does it work in Windows 10?

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 11, 2016, 02:41:04 pm
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US is cure for Windows 7 EN
How that works in different version of Windows 7? Like UK?

EDIT:
Works in Windows 8.1 FI
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 02:55:49 pm
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US is cure for Windows 7 EN
How that works in different version of Windows 7? Like UK?

Earlier I was going to ask that but didn't.

It works ok here on Win7. Does it work for Frankie.

Does it work for Win10?

John
Title: Re: Last Update for FindFile
Post by: frankie on May 11, 2016, 03:26:32 pm
It seems to work, but if I set spanish I get italian again  :o
I can't consider it a success...  >:(
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 03:35:09 pm
It seems to work, but if I set spanish I get italian again  :o
I can't consider it a success...  >:(

But this does right ?

Code: [Select]
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK

STRINGTABLE
{
  1, "Explore Folder"

Timo said it worked on his windows 7.

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 11, 2016, 04:14:09 pm
Only
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
or
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
works somehow.
Empty LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL is useless.
Title: Re: Last Update for FindFile
Post by: frankie on May 11, 2016, 04:24:24 pm
No.
It doesn't work.
Using:
Code: [Select]
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_USSeems to work, but after I added the italian translation it give me italian if I set spanish language.
I Attach the new rc file with italian translation.
In short the problem is not present when using a localization for which the translation exists, but when it is invoked in a locale that is not in the resource. In this case the system picks the language it wants...  >:(
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 04:46:00 pm
Thanks for the new translation Frankie.

I will stick with this code

Code: [Select]
//Set english as default language for those not supported
switch (GetThreadLocale())
{
case (0x0809): // English (UK)
case (0x040c): // French
case (0x0407): // German (Standard)
case (0x0416): // Portuguese (Brazil)
case (0x040b): // Finnish
case (0x0419): // Rusian
case (0x0413): // Dutch
break;
default:
SetLanguage(0x0809);
}

It should always work.

Thanks to both of you for your help.

John
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 05:20:53 pm
Frankie, you didn't translate all the strings.  ???

John
Title: Re: Last Update for FindFile
Post by: frankie on May 11, 2016, 07:11:07 pm
John,
some definitions don't have a direct translation in italian, and usually the english word has become standard name.

Anyway I still don't like the workaround  >:(. Is horrible, and difficult to maintain (you have to remember to update the list of languages in the check code).
So I have prepared a different approach. In each translation I added a string that is the language code stringized (a neologism ;)). Then I modified the check in the following way:
Code: [Select]
void IsLanguageSupported(void)
{
//Check if local language is supported, and if not set english as default
char buf[16];
if (LoadStringA(g_hInst, HAVE_LANGUAGE, buf, 16)) //Load the system choosed locale string
{
WORD ResLid = strtol(buf, NULL, 16);
WORD SysLid = GetThreadLocale();
if (SysLid == ResLid) //We got our locale
return; //nothing to do.

//Do we match at least the primary language?
if (PRIMARYLANGID(SysLid) == PRIMARYLANGID(ResLid))
return; //Yes primary language matches. We will get close translation.
}

//If we are here we couldn't have load the string or we haven't find a suitable
//language. We then stick to english uk as default.
SetLanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK));
}
This simplify the maintenance because it is one of the required strings and you can't omit it, and any new language will be automatically recognized.
Find attached the emended FindFileUni.rc and FindFileRes.h.
Have a nice evening.
Title: Re: Last Update for FindFile
Post by: JohnF on May 11, 2016, 07:46:44 pm
Thanks again.

This is the string section that you missed.

Code: [Select]
STRINGTABLE
{
#ifdef FF64
  64, "FindFile64 Messaggio..."
#else
  64, "FindFile32 Messaggio..."
#endif
  65, "OK"
  66, "SendTo Menu Items"
  67, "Add or Edit a SendTo Menu Item"
  68, "Edit Item"
  69, "Edit SendTo Menu"
  70, "Program"
  71, "Choose Either a Folder or Program and enter the Display Name"
  72, "Display Name"
  73, "The Folder Or Program"
  74, "Clear All"
  75, "Reset"
  76, "More Than Bytes"
  77, "Less Than Bytes"
  78, "Fill in one or more Parameters (dates require dd/mm/yyyy)"
  79, "After"
}

I will try out that new code.

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 11, 2016, 07:59:42 pm
Final time.
I comment out finnish resource and other useless and chance line before english string table:
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK
to
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
and i got english text, before that it was german.

Title: Re: Last Update for FindFile
Post by: frankie on May 11, 2016, 11:11:00 pm
John you're right  :-[
I have to complete!

Timo it seems that the resource is selected casually using the first one it finds.
I'm sure that there is a reason behind it, but I've not identified it :(
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 08:02:30 am
John you're right  :-[
I have to complete!

Timo it seems that the resource is selected casually using the first one it finds.
I'm sure that there is a reason behind it, but I've not identified it :(


I look forward to the new translation. :)

We all thought that it would default to English and I think Timo is right, it won't default to LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK but will to LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US.

Frankie please give it one more go, comment out your Italian strings set the two LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US and don't try to set anything, just let it run. I suspect you will get English.

Btw, both you code solutions are fine but I'd rather use the language defines.

John
Title: Re: Last Update for FindFile
Post by: frankie on May 12, 2016, 11:16:02 am
I should have cleared the points now  :) (or at least I hope so  :P)
Let expose the points:
Conclusion:

And now the missing italian translations:
Code: [Select]
STRINGTABLE
{
#ifdef FF64
  64, "FindFile64 Messaggio..."
#else
  64, "FindFile32 Messaggio..."
#endif
  65, "OK"
  66, "Voci del menu SendTo"
  67, "Aggiungi o edita voci del menu SendTo"
  68, "Edita Voce"
  69, "Edita Menu SendTo"
  70, "Programma"
  71, "Scegliere una cartella o un  programma e inserire il nome da visualizzare"
  72, "Visualizza Nome"
  73, "Cartella o Programma"
  74, "Cancella tutto"
  75, "Ripristina"
  76, "Più di Bytes"
  77, "Meno di Bytes"
  78, "Compilare uno o più parametri (date in formato gg/mm/aaaa)"
  79, "Dopo"
}
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 11:30:06 am
Thank you for the translation.

Here, the resources will default to SUBLANG_ENGLISH_US even when SUBLANG_ENGLISH_UK is present.

So unless specifically asked for UK, I will get US. This is on Win7. I think the same applies to Timo's Win7.

I will think about the points you raised.  :)

John
Title: Re: Last Update for FindFile
Post by: frankie on May 12, 2016, 11:57:59 am
John the reason, as I told you, is that win7 is broken, and select ENGLISH_US=0x0409 that is less tha ENGLISH_UK=0x0809.
Make a trial add danish=0x0406, and check if default is still ENGLISH_US.  ;)
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 12:36:38 pm
John the reason, as I told you, is that win7 is broken, and select ENGLISH_US=0x0409 that is less tha ENGLISH_UK=0x0809.
Make a trial add danish=0x0406, and check if default is still ENGLISH_US.  ;)

Yes it is, see image.

Code: [Select]
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".

LANGUAGE LANG_DANISH,SUBLANG_DANISH_DENMARK
STRINGTABLE {1, "Danish"}

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK
STRINGTABLE{1, "EnglishUS"}

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
STRINGTABLE{1, "EnglishUS"}

And the code of the project

Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void SetLanguage(LANGID lid);
void __cdecl WinMainCRTStartup(void)
{
TCHAR szTmp[256];
LoadString(GetModuleHandle(NULL), 1, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
MessageBox(0,szTmp,0,MB_OK);

ExitProcess(0);
}
void SetLanguage(LANGID lid)
{
typedef LANGID (WINAPI *fnPtr) (LANGID wReserved);

if ((GetVersion() & 0x00FF) > 5) {// Vista =>
LANGID lid2;
fnPtr pSetThreadUILanguage  = (fnPtr)GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")), "SetThreadUILanguage");
if (pSetThreadUILanguage)
// lid2 should equal lid
lid2 = (*pSetThreadUILanguage)(lid);
} else {
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
}
}

As for Timo's chinese experiment, if you take away the default the OS can't but choose something else.

John
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 12:45:11 pm
However my GetThreadLocale(); returns US and I don't know how to change that to UK. I have set UK everywhere that I've seen on system settings.

EDIT: Both GetSystemDefaultLCID(); and GetUserDefaultLCID(); return UK.

EDIT1:
In the registry is this

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-US]
"LCID"=dword:00000409
"Type"=dword:00000091

Do I need to add an entry for the UK

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-UK]
"LCID"=dword:00000809
"Type"=dword:00000091    // what is this?

John

Title: Re: Last Update for FindFile
Post by: TimoVJL on May 12, 2016, 01:16:24 pm
Code: [Select]
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment (lib, "msvcrt.lib")
int __cdecl DisplayThreadLocale(void)
{
LCID lcidt = GetThreadLocale();
LCID lcids = GetSystemDefaultLCID();
LCID lcidu = GetUserDefaultLCID();
LCID lcidui = GetThreadUILanguage();
wprintf(L"ThreadLocale\t\t0x%04X\nSystemDefaultLCID\t0x%04X\n"
"UserDefaultLCID\t\t0x%04X\nThreadUILanguage\t0x%04X\n",
lcidt, lcids, lcidu, lcidui);
return 0;
}

//int main(void)
void __cdecl mainCRTStartup(void)
{
DisplayThreadLocale();
ExitProcess(0);
return 0;
}
outputs in Windows 7 EN with FI locale
Code: [Select]
ThreadLocale            0x040B
SystemDefaultLCID       0x040B
UserDefaultLCID         0x040B
ThreadUILanguage        0x0409
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 01:37:42 pm
EDIT:

Here is my image, changed back as it was before I changed the registry. :)

409 in yours too.

John
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 04:02:31 pm
Anyway guys we can stop all this - as I said before I will use code to ensure that English is selected when the other languages are not present.

IsLanguageSupported()

BUT why have Timo and I got 0x0409 set for threads?

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 12, 2016, 04:19:05 pm
My Windows 7 Home Premium is EN version.
Title: Re: Last Update for FindFile
Post by: frankie on May 12, 2016, 04:36:18 pm
John, there are too many possibilities for which the preferred GUI LCID is set differently, even some well known buggy sw (you can google).
Anyway let me give a couple of suggestions, add a language selection menu, put translations in separate files (i.e. en.rc for english, it.rc for italian and so on.
A fast way to overcome bad GUI LCID could be:
Code: [Select]
SetLanguage(GetThreadLocale());
Forcing GUI LCID to the local thread LCID, but don't know how it could be correct, because maybe the user voluntarily set it to a different language.
Title: Re: Last Update for FindFile
Post by: JohnF on May 12, 2016, 05:46:42 pm
Thank you both for all your efforts it's been really appreciated and a pleasure.

John
Title: Re: Last Update for FindFile
Post by: TimoVJL on May 13, 2016, 12:47:36 pm
A fast way to overcome bad GUI LCID could be:
Code: [Select]
SetLanguage(GetThreadLocale());
Forcing GUI LCID to the local thread LCID, but don't know how it could be correct, because maybe the user voluntarily set it to a different language.
Not good for Windows 10 non US.
Windows 10 FI
Code: [Select]
ThreadLocale            0x0809
SystemDefaultLCID       0x040B
UserDefaultLCID         0x040B
ThreadUILanguage        0x040B
Title: Re: Last Update for FindFile
Post by: JohnF on May 19, 2016, 02:20:18 pm
This is definitely the last update for FindFile.

From the change log
Code: [Select]
=================================================
18th May 2016. Version 3.2 (JF)
=================================================
Frankie supplied an Italian translation of the resource strings
which has been added to the project.

On the 'Send To' context menu one could Send To a folder but
not a drive - fixed.

Added Unicode switch to Stephan Zorn's command line code.
You might be able to guess the switch  /U+

Bug in DeleteListViewEntres() Fixed
swprintf(s, PATH_SIZE, s, g_fileopts.count);

There were occasions when the icon would continue to be
displayed in the image window box when it shouldn't.
Added this code to function ClearPreview()

if(g_hIcon != NULL){
DestroyIcon(g_hIcon);
g_hIcon = NULL;
}

Download from Here (http://www.johnfindlay.plus.com/pellesc/utils/utils.html)

John
Title: Re: Last Update for FindFile
Post by: JohnF on June 03, 2016, 05:36:49 pm
Although all my system settings were set to English UK, using GetThreadLocale() returned English US.

Found this on stackoverflow forum.

On the forum someone suggested that (on Windows 7) one has to first change to a different language and then back to ones own. It worked, now I get English UK when using GetThreadLocale().

John