Board index » cppbuilder » Non-unicode language change
bar
![]() CBuilder Developer |
bar
![]() CBuilder Developer |
Non-unicode language change2008-03-31 01:45:39 AM cppbuilder26 Hi all Anybody give me some details how to change the value of Non-Unicode Language setting programatically. Thanks SA |
maeder
![]() CBuilder Developer |
2008-03-31 11:16:10 PM
Re:Non-unicode language change
"bar" < XXXX@XXXXX.COM >writes:
QuoteAnybody give me some details how to change the value of Non-Unicode |
bar
![]() CBuilder Developer |
2008-04-01 05:06:36 PM
Re:Non-unicode language change
Ok.
In one of my program, i am creating some labels and menus at run-time. I have to assign Arabic text to the labels captions and menus. As it should be, when the value for the "Language and Non-Unicode" set to other than Arabic, I am getting all ???? mark symbols for the labels and menus. So i want to check atleast when the program runs for the first time, detect the value for "Language and Non-Unicode" and set to Arabic, if not set. If it is possible through program. Is it must to restart the pc?. I will be happy, is there anyway to give the sepecific language value only for the my program. Thanks SA {smallsort} |
Bob Gonder
![]() CBuilder Developer |
2008-04-01 10:27:02 PM
Re:Non-unicode language change
bar wrote:
QuoteI will be happy, is there anyway to give the sepecific language value only |
bar
![]() CBuilder Developer |
2008-04-03 02:11:46 AM
Re:Non-unicode language change
Hi Bob Gonder
I have Non-Unicode Language set to English (United States). If i run the program i'll see ????. I placed the code in the WinMain() function int iLang = 0; iLang = MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_KUWAIT),SORT_DEFAULT); SetThreadLocale(iLang); //returns true But still the captions are not changing. Thanks SA |
Vladimir Stefanovic
![]() CBuilder Developer |
2008-04-03 03:48:42 AM
Re:Non-unicode language changeQuoteBut still the captions are not changing. "Language for non-Unicode programs" by code. That operation typically is followed by two dialogs (CP>Regional and Language Options>Advanced) to choose loading from HD or from CD and confirmation to restart PC. Afterall I saw cluster of REG entries specially designed to patch existing entries, which is completely wrong aproach in my oppinon. What you can test, in addition to SetThreadLocale() is to make few helper functions to change CodePage of concrete objects. The example shown is for use with resource files, and you should be interested in CodepageToCharset(). (I copied this from one old thread here) // MyStrings.rh #define IDS_CANCEL 27114 // Strings.rc #pragma code_page(1252) #include "MyStrings.rh" STRINGTABLE LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US BEGIN IDS_CANCEL, "Cancel" END STRINGTABLE LANGUAGE LANG_CZECH, SUBLANG_DEFAULT BEGIN IDS_CANCEL, "Zrusit" END Then, in your application, create a couple of helper functions to assist you when setting the language: static const TFontCharset CodepageToCharset( unsigned int cp ) { CHARSETINFO csi; if ( (cp == 0) || (!TranslateCharsetInfo( (unsigned long *)cp, &csi, TCI_SRCCODEPAGE )) ) { return OEM_CHARSET; } return (TFontCharset)csi.ciCharset; } static AnsiString InternalLoadStr( int ErrorCode ) { const int MaxResourceBufferSize = 4096; // maximum resource string length is 4095 bytes char string[MaxResourceBufferSize]; LoadString( GetModuleHandle(0), ErrorCode, string, MaxResourceBufferSize ); return AnsiString( string ); } Finally, set the thread locale to the desired language: SetThreadLocale( 0x0409 ); // U.S. English btnCancel->Font->Charset = CodepageToCharset( 1252 ); // western codepage btnCancel->Caption = InternalLoadStr( IDS_CANCEL ); SetThreadLocale( 0x0405 ); // Czech locale btnCancel->Font->Charset = CodepageToCharset( 1250 ); // eastern europe codepage btnCancel->Caption = InternalLoadStr( IDS_CANCEL ); Anyway, look here: tinyurl.com/2g3woz Best Regards, Vladimir Stefanovic |