Lesson 3: Application Localization

Resource Files

A resource file is a useful mechanism for separating localizable information from code. String resources refer to the text that appears in the application's user interface. They include items such as menus , dialog boxes, and informational, alert, and error messages. If an application will be used in a locale other than the one in which it was developed, these resources must be localized.

Storing Strings in Resource Files

When writing Visual Basic code, the LoadResString , LoadResPicture , and LoadResData functions are used in place of references to string literals, pictures, and data. Storing such elements in a resource file offers two benefits:

  • Performance and capacity are increased because strings, bitmaps, icons, and data can be loaded on demand from the resource file, instead of being loaded at once when a form or a module is loaded.
  • The resources that need to be translated are isolated in one resource file. There is no need to access the source code or recompile the application.
Example

This example uses the Visual Basic LoadResString function. An index argument is used as an integer specifying the identifier (ID) of the data in the resource file.

 strValue = LoadResString(Index) 


Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net