Multi-Language Add-In for VB6

Multi-Language Add-In for VB6

let os select language first time


I want to make a mix between OS selection and User selection of the language.

The first time the app is launched, I want the language to be automatically selected with the one of the OS.
But I still want the user to be able to switch later. I will provide a menu for this.

Any idea how i can achieve this?



Hi Marc,

I would use the option to select the language from the application. The only extra trick you need is to fetch the current language (i.e. selected by OS) when the program starts.

I think that you can do this using the API function GetThreadLocale

Private Declare Function GetThreadLocale Lib "KERNEL32" () As Long

Dim LCID As Long
LCID = GetThreadLocale()
ml_ChangeLanguage LCID, ""

If you are using the LanguageSelect form based on the template, you might want to save this selection as if the user had selected it.

SaveSetting App.EXEName, "MultiLang", "LangId", ml_CurrentLanguageId
SaveSetting App.EXEName, "MultiLang", "LangName", ml_LanguageName(ml_CurrentLanguageId)
SaveSetting App.EXEName, "MultiLang", "ShowDialog", 0

Storing the LangName property is not really necessary.

By the way, the template saves the ShowDialog property as a boolean value in a way I would now avoid. When VB6 stores a boolean value it will store it as a localized string (True, False, Vrai, Faux, Wahr, Falsch, ...). If you try to read it back using a different language setting it will fail. I would prefer to store it as a numeric value, e.g.

'Stores boolean as a localized string
SaveSetting App.EXEName, "MultiLang", "ShowDialog", Showonstartup
'Stores boolean as a numeric value
SaveSetting App.EXEName, "MultiLang", "ShowDialog", iif(Showonstartup,1,0)

but that has nothing to do with your original question. smile