If any of the string properties in a control container file or a designer selected for localization have been translated, when building an RSV VBLM appends a VBLM_SetProperties procedure to its code section, and inserts a call to this procedure at the top of the initialization event procedure.*

VBLM_SetProperties contains code that sets the file's visible interface to the currently selected language by calling the string replacement function for each translated property:

Sub VBLM_SetProperties ()

 frmMain.Caption = VBLM_RTString(860)

 cmd(0).Caption = VBLM_RTString(269)

 cmd(1).Caption = VBLM_RTString(127)

End Sub

 

Additional content of the procedure depends on the setting of various options, including form initialization and runtime dimension switching.

Trap Errors

If this option, set on the Form Initialization page of the Build window, is checked, VBLM wraps the procedure with On Error Resume Next / On Error Goto 0. This avoids problems when read-only properties have been inadvertently translated (eg the text property of a drop-down list). Tests show that this actually speeds up execution a bit, but if you hate Resume Next, you can uncheck the option and deal with any errors on your own.

Prepend Me

If this form init option is checked,VBLM prepends "Me." to all control names in the procedure, to avoid errors when controls are named using VB keywords (bad practice, but allowed). Tests show that "Me!" slows execution a bit. If you don't use keywords as names (good for you!), you can uncheck this without causing problems.

Note: "Me" is not legal in property pages, user controls or designers, so VBLM ignores this setting for these file types

Include User Code

If this form init option is checked, VBLM will include user-defined prefix code at the beginning of VBLM_SetProperties and user-defined suffix code at the end. This allows user customization: see Include User Code for details.

Retain Original Strings as Comments

If this Misc build option is checked, the original property strings will be appended as comments.

 

If all of these options are checked, the above sample would look like this:

Sub VBLM_SetProperties ()

 Call VBLM_UserPrefixCode(Me)

 On Error Resume Next

 frmMain.Caption = VBLM_RTString(860)  '"My App"

 Me.cmd(0).Caption = VBLM_RTString(269) '"&OK"

 Me.cmd(1).Caption = VBLM_RTString(127) '"&Help"

 On Error GoTo 0

 Call VBLM_UserSuffixCode(Me)

End Sub

 

Handling Enumerated Properties

If the control container has a VB4+ list or combo box with an enumerated list property stored in its binary stash file (see string properties and binary stash files), VBLM adds special handling code to perform the switch. First it clears the list, then it checks/fixes mis-aliased crlfs, and then it adds each item (which are separated by tildes).

Dim cp as Integer, sTmp as String 

sTmp = VBLM_RTString(9) 

Do 'check/fix any empty list items mis-aliased as crlfs

cp = Instr(sTmp, Chr$(13)) 

If cp then 

sTmp = Left$(sTmp, cp - 1) & "~~" & Mid$(sTmp, cp + 2) 

Else Exit Do 

End If 

Loop  

Me.List1.Clear 

Do 

cp = Instr(sTmp, "~") 

If cp Then 

Me.List1.AddItem Left$(sTmp, cp - 1) 

sTmp = Mid$(sTmp, cp + 1) 

Else 

Me.List1.AddItem sTmp 

Exit Do

End If 

Loop 

 

Finally, if the form has 3rd party controls with other enumerated properties from the binary stash, VBLM adds the following advice at the end of VBLM_SetProperties:

'NOTE: This line is commented because the property is enumerated and stored in the frx file

'VBLM cannot set it by simple assignment; you need to use the control's methods to do so.

' Me.Mh3dList1.ColTitle = VBLM_RTString(45) ' "Column 0~Column 1"

 

Runtime Dimension Switching

If VBLM is configured to implement runtime dimension switching, the code to do so is inserted into VBLM_SetProperties. This code and the option settings that shape it are complex enough to merit their own topic: see implementing runtime dimension switching.

Sub VBLM_SetProperties ()

 

 'Language switching code inserted here

 

 'Dimension switching code inserted here

 

End Sub

 

Inserting the Call to VBLM_SetProperties()

Having built the VBLM_SetProperties() procedure, VBLM inserts a call to it. Where it does so depends on the file type:

image\DOT_SM.gif For form and MDI form files, VBLM inserts the call at the top of the load event procedure.

image\DOT_SM.gif For property pages, VBLM inserts the call at the top of the Initialize event procedure.

image\DOT_SM.gif For user controls and document objects, by default VBLM inserts the call at the top of the InitProperties event procedure. However, you can change this and force VBLM to add the call to the Initialize event instead by changing the Non-Form Default Set Properties Event.

image\DOT_SM.gif In each case, if the file does not have the procedure in which VBLM needs to insert the call, VBLM creates one.

Enable On-The-Fly Switching

If this option is checked, VBLM adds a label control to each file with a VBLM_SetProperties procedure, inserts a call to the procedure in the label's change event, and appends an app-wide instantaneous language-changing procedure to the RSV support module. This procedure works by changing the label of each displayed control container, thus triggering a refresh. See Enabling On-The-Fly Switching for details.