home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / VB98 / TEMPLATE / CODE / LOADRES.BAS next >
Encoding:
BASIC Source File  |  1998-06-18  |  2.2 KB  |  78 lines

  1. Attribute VB_Name = "modLoadRes"
  2. ' This procedure will load resource strings associated with controls on a
  3. ' form based on the Resource ID stored in the Tag property of  a control.
  4.  
  5. ' The resource string will be loaded into a control's property as follows:
  6. ' Object      Property
  7. ' Form        Caption
  8. ' Menu        Caption
  9. ' TabStrip    Caption, ToolTipText
  10. ' Toolbar     ToolTipText
  11. ' ListView    ColumnHeader.Text
  12.  
  13. Sub LoadResStrings(frm As Form)
  14.   On Error Resume Next
  15.   
  16.   Dim ctl As Control
  17.   Dim obj As Object
  18.   
  19.   'set the form's caption
  20.   If IsNumeric(frm.Tag) Then
  21.     frm.Caption = LoadResString(CInt(frm.Tag))
  22.   End If
  23.   
  24.   'set the controls' captions using the caption
  25.   'property for menu items and the Tag property
  26.   'for all other controls
  27.   For Each ctl In frm.Controls
  28.     Err.Clear
  29.     If TypeName(ctl) = "Menu" Then
  30.       If IsNumeric(ctl.Caption) Then
  31.         If Err = 0 Then
  32.           ctl.Caption = LoadResString(CInt(ctl.Caption))
  33.         End If
  34.       End If
  35.     ElseIf TypeName(ctl) = "TabStrip" Then
  36.       For Each obj In ctl.Tabs
  37.         Err.Clear
  38.         If IsNumeric(obj.Tag) Then
  39.           obj.Caption = LoadResString(CInt(obj.Tag))
  40.         End If
  41.         'check for a tooltip
  42.         If IsNumeric(obj.ToolTipText) Then
  43.           If Err = 0 Then
  44.             obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
  45.           End If
  46.         End If
  47.       Next
  48.     ElseIf TypeName(ctl) = "Toolbar" Then
  49.       For Each obj In ctl.Buttons
  50.         Err.Clear
  51.         If IsNumeric(obj.Tag) Then
  52.           obj.ToolTipText = LoadResString(CInt(obj.Tag))
  53.         End If
  54.       Next
  55.     ElseIf TypeName(ctl) = "ListView" Then
  56.       For Each obj In ctl.ColumnHeaders
  57.         Err.Clear
  58.         If IsNumeric(obj.Tag) Then
  59.           obj.Text = LoadResString(CInt(obj.Tag))
  60.         End If
  61.       Next
  62.     Else
  63.       If IsNumeric(ctl.Tag) Then
  64.         If Err = 0 Then
  65.           ctl.Caption = LoadResString(CInt(ctl.Tag))
  66.         End If
  67.       End If
  68.       'check for a tooltip
  69.       If IsNumeric(ctl.ToolTipText) Then
  70.         If Err = 0 Then
  71.           ctl.ToolTipText = LoadResString(CInt(ctl.ToolTipText))
  72.         End If
  73.       End If
  74.     End If
  75.   Next
  76.  
  77. End Sub
  78.