• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VB Question

alaniscool

Senior member
I have an ActiveX control which has a Resource file with two string tables: one for English and one for German, which is use to load the caption on a label on the control. To do this, I use LoadResString() in UserControl_InitProperties() and UserControl_ReadProperties(). I put the control in a separate form, and compile it as an exe. Now I try to run the exe in the US locale and the German locale, and in both cases the English string gets loaded. Does anyone know why?

Thanks.
 
How are you discerning locale? At some point you'll need to GetLocaleInfo() to discern which strings you'll be pulling from the resource file.

Also, code is helpful. Hard to see any issue with your code when you don't post any...
 
Here's the code that loads the string from the resource table in readproperties(), it's the same code in initproperties().

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Label1.Caption = LoadResString(101)
End Sub

101 is the entry to my english and german string.

I thought that LoadResString() will automatically pick the correct string table based on the locale of the system. If that's not the case, how should this code look like to load the german string in the usercontrol?

Thanks.
 
LoadResString simply loads the specified string from the resource file. It is indifferent to the locale. You need to do what Descartes said (Win32API) to determine the locale.
 
So how do I tell the resource file that I want to load the string from the German string table after getting the locale information with GetLocaleInfo()?
 
That's really up to you. I don't know how you've designed your application well enough to tell you how you need to integrate the functionality; however...

The easier way would be to call GetUserDefaultLangID() and then simply do a switch/Select against the known language identifiers for English and German. You then simply need to pull the appropriate ID from the resource file.
 
Back
Top