Public Sub LoadResStrings(frm As Form) '读取整个窗体的资源信息
Dim objCtrl As Control
Dim obj As Object
Dim fnt As Object
Dim sCtlType As String
Dim nVal As Integer
Dim i As Integer
On Error Resume Next
If frm.Caption <> "" Then
frm.Caption = LoadResString(CInt(frm.Caption))
End If
' 窗体Font属性
' Set form font
Set fnt = frm.Font
fnt.Name = "宋体"
fnt.Size = 9
' 装入各控件的资源串和设置字体
' Set the resource text and font of every control
For Each objCtrl In frm.Controls
sCtlType = TypeName(objCtrl)
objCtrl.Font = fnt
objCtrl.Font.Size = fnt.Size
' 设置Lable的资源串
' Set Lable resource text
If sCtlType = "Label" Then
objCtrl.Caption = LoadResString(CInt(objCtrl.Tag))
' 设置Menu的资源串
' Set Menu resource text
ElseIf sCtlType = "Menu" Then
If objCtrl.Caption <> "-" Then
objCtrl.Caption = LoadResString(CInt(objCtrl.Caption))
End If
' 设置TabStrip的资源串
' Set TabStrip resource text
ElseIf sCtlType = "TabStrip" Then
For Each obj In objCtrl.Tabs
obj.Caption = LoadResString(CInt(obj.Tag))
obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
Next
' 设置SSTab的资源串
' Set SSTab resource text
ElseIf sCtlType = "SSTab" Then
For i = 0 To objCtrl.Tabs - 1
objCtrl.TabCaption(i) = LoadResString(CInt(objCtrl.TabCaption(i)))
Next
' 设置Toolbar的资源串
' Set Toolbar resource text
ElseIf sCtlType = "Toolbar" Then
For Each obj In objCtrl.Buttons
obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
obj.Description = obj.ToolTipText
For i = 1 To obj.ButtonMenus.Count
obj.ButtonMenus(i).Text = LoadResString(CInt(obj.ButtonMenus(i).Tag))
Next
Next
' 设置ListView的资源串
' Set ListView resource text
ElseIf sCtlType = "ListView" Then
For Each obj In objCtrl.ColumnHeaders
obj.Text = LoadResString(CInt(obj.Tag))
Next
' TreeView的资源串
' Set TreeView resource text
ElseIf sCtlType = "TreeView" Then
For Each obj In objCtrl.ColumnHeaders
obj.Text = LoadResString(CInt(obj.Tag))
Next
ElseIf sCtlType = "CommandButton" Then
objCtrl.Caption = LoadResString(CInt(objCtrl.Tag))
' 设置其它控件的资源串
' Set else control's resource text
Else
nVal = 0
nVal = Val(objCtrl.Tag)
If nVal > 0 Then objCtrl.Caption = LoadResString(nVal)
nVal = 0
nVal = Val(objCtrl.ToolTipText)
If nVal > 0 Then objCtrl.ToolTipText = LoadResString(nVal)
End If
Next
End Sub
Dim objCtrl As Control
Dim obj As Object
Dim fnt As Object
Dim sCtlType As String
Dim nVal As Integer
Dim i As Integer
On Error Resume Next
If frm.Caption <> "" Then
frm.Caption = LoadResString(CInt(frm.Caption))
End If
' 窗体Font属性
' Set form font
Set fnt = frm.Font
fnt.Name = "宋体"
fnt.Size = 9
' 装入各控件的资源串和设置字体
' Set the resource text and font of every control
For Each objCtrl In frm.Controls
sCtlType = TypeName(objCtrl)
objCtrl.Font = fnt
objCtrl.Font.Size = fnt.Size
' 设置Lable的资源串
' Set Lable resource text
If sCtlType = "Label" Then
objCtrl.Caption = LoadResString(CInt(objCtrl.Tag))
' 设置Menu的资源串
' Set Menu resource text
ElseIf sCtlType = "Menu" Then
If objCtrl.Caption <> "-" Then
objCtrl.Caption = LoadResString(CInt(objCtrl.Caption))
End If
' 设置TabStrip的资源串
' Set TabStrip resource text
ElseIf sCtlType = "TabStrip" Then
For Each obj In objCtrl.Tabs
obj.Caption = LoadResString(CInt(obj.Tag))
obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
Next
' 设置SSTab的资源串
' Set SSTab resource text
ElseIf sCtlType = "SSTab" Then
For i = 0 To objCtrl.Tabs - 1
objCtrl.TabCaption(i) = LoadResString(CInt(objCtrl.TabCaption(i)))
Next
' 设置Toolbar的资源串
' Set Toolbar resource text
ElseIf sCtlType = "Toolbar" Then
For Each obj In objCtrl.Buttons
obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
obj.Description = obj.ToolTipText
For i = 1 To obj.ButtonMenus.Count
obj.ButtonMenus(i).Text = LoadResString(CInt(obj.ButtonMenus(i).Tag))
Next
Next
' 设置ListView的资源串
' Set ListView resource text
ElseIf sCtlType = "ListView" Then
For Each obj In objCtrl.ColumnHeaders
obj.Text = LoadResString(CInt(obj.Tag))
Next
' TreeView的资源串
' Set TreeView resource text
ElseIf sCtlType = "TreeView" Then
For Each obj In objCtrl.ColumnHeaders
obj.Text = LoadResString(CInt(obj.Tag))
Next
ElseIf sCtlType = "CommandButton" Then
objCtrl.Caption = LoadResString(CInt(objCtrl.Tag))
' 设置其它控件的资源串
' Set else control's resource text
Else
nVal = 0
nVal = Val(objCtrl.Tag)
If nVal > 0 Then objCtrl.Caption = LoadResString(nVal)
nVal = 0
nVal = Val(objCtrl.ToolTipText)
If nVal > 0 Then objCtrl.ToolTipText = LoadResString(nVal)
End If
Next
End Sub