home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic 6.0 Utilities / Multi-Language Add-In for Visual Basic 6.0 / MultiLang.msi / _F8FA67019FD611D5BEFD0020182C1E5C (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-09-12  |  5.0 KB  |  137 lines

  1. VERSION 5.00
  2. Begin VB.Form LanguageSelect 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Select Language"
  5.    ClientHeight    =   2796
  6.    ClientLeft      =   36
  7.    ClientTop       =   336
  8.    ClientWidth     =   5088
  9.    Icon            =   "LanguageSelect.frx":0000
  10.    LinkTopic       =   "Form2"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   2796
  14.    ScaleWidth      =   5088
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.CheckBox chkShowOnStartup 
  18.       Caption         =   "Show this dialog when the program starts"
  19.       Height          =   252
  20.       Left            =   120
  21.       TabIndex        =   2
  22.       Top             =   2280
  23.       Width           =   3492
  24.    End
  25.    Begin VB.CommandButton OkButton 
  26.       Caption         =   "OK"
  27.       Default         =   -1  'True
  28.       Height          =   372
  29.       Left            =   3840
  30.       TabIndex        =   1
  31.       Top             =   2280
  32.       Width           =   1092
  33.    End
  34.    Begin VB.ListBox LanguageList 
  35.       Height          =   1968
  36.       Left            =   120
  37.       TabIndex        =   0
  38.       Top             =   120
  39.       Width           =   4812
  40.    End
  41. Attribute VB_Name = "LanguageSelect"
  42. Attribute VB_GlobalNameSpace = False
  43. Attribute VB_Creatable = False
  44. Attribute VB_PredeclaredId = True
  45. Attribute VB_Exposed = False
  46. Option Explicit
  47. Private ShowOnStartup As Boolean
  48. Private WithEvents ml_RuntimeSupport As MLRUNTIMELib.MLSupport
  49. Attribute ml_RuntimeSupport.VB_VarHelpID = -1
  50. Public Sub ShowDialog(Optional ByVal IsStartup As Boolean = True)
  51.   Load Me
  52.   'This function can be called from Sub Main to:
  53.   '- read settings from the registry and
  54.   '- show the LanguageSelect Dialog.
  55.   'The LanguageSelect dialog has a check box to specify whether it
  56.   'should be shown on startup. Your program should provide some method
  57.   'other method to show this dialog, if the user disables it!
  58.   'The VB SaveSetting/GetSetting functions store the settings in
  59.   '"HKEY_CURRENT_USER\Software\VB and VBA Program Settings".
  60.   'You may want to replace these functions with Windows API functions
  61.   'to store the settings somewhere else, such as
  62.   '"HKEY_CURRENT_USER\Software\<my company>".
  63.   If IsStartup Then
  64.     Dim LangId As Long
  65.     Dim Lang As String
  66.     'Read settings from registry
  67.     LangId = GetSetting(App.EXEName, "MultiLang", "LangId", 0)
  68.     Lang = GetSetting(App.EXEName, "MultiLang", "LangName")
  69.     'Select the language specified in the registry
  70.     ml_ChangeLanguage LangId, Lang
  71.     'Store the language in the runtime support object, so that seperately
  72.     'compiled components (.ocx, .dll) can start up in the same language.
  73.     Set ml_RuntimeSupport = New MLSupport                                   'MLRUNTIMESUPPORT
  74.     ml_RuntimeSupport.SetLanguage LangId, Lang                              'MLRUNTIMESUPPORT
  75.   End If
  76.   'Always read the ShowOnStartup flag from the registry
  77.   ShowOnStartup = GetSetting(App.EXEName, "MultiLang", "ShowDialog", True)
  78.   'Initialise controls on the form
  79.   InitialiseForm
  80.   'Show the language select dialog, unless the user deselected this option.
  81.   If ShowOnStartup Or Not IsStartup Then
  82.     Me.Show vbModal
  83.           
  84.     'Save settings in the registry
  85.     SaveSetting App.EXEName, "MultiLang", "LangId", ml_CurrentLanguageId
  86.     SaveSetting App.EXEName, "MultiLang", "LangName", ml_LanguageName(ml_CurrentLanguageId)
  87.     SaveSetting App.EXEName, "MultiLang", "ShowDialog", ShowOnStartup
  88.   End If
  89.   Unload Me
  90. End Sub
  91. Private Sub InitialiseForm()
  92.   Dim Index      As Long
  93.   Dim LanguageID As Long
  94.   Dim LanguageArray
  95.   LanguageArray = ml_LanguageIds
  96.   With LanguageList
  97.     .Clear
  98.     For Index = LBound(LanguageArray) To UBound(LanguageArray)
  99.       LanguageID = LanguageArray(Index)
  100.       .AddItem ml_LanguageName(LanguageID)
  101.       .ItemData(.NewIndex) = LanguageID
  102.       
  103.       If LanguageID = ml_CurrentLanguageId Then
  104.         .Selected(Index) = True
  105.       End If
  106.     Next
  107.   End With
  108.   chkShowOnStartup.Value = IIf(ShowOnStartup, vbChecked, vbUnchecked)
  109. End Sub
  110. Private Sub LanguageList_DblClick()
  111.   OkButton_Click
  112. End Sub
  113. Private Sub OkButton_Click()
  114.   With LanguageList
  115.     If .ListIndex <> -1 Then
  116.       ShowOnStartup = (chkShowOnStartup = vbChecked)
  117.       ml_CurrentLanguageId = .ItemData(.ListIndex)
  118.       ml_RuntimeSupport.SetLanguage ml_CurrentLanguageId, ml_LanguageName(ml_CurrentLanguageId)    'MLRUNTIMESUPPORT
  119.       Me.Hide
  120.       
  121.     End If
  122.   End With
  123. End Sub
  124. Private Sub ml_RuntimeSupport_LanguageChanged(ByVal LanguageID As Long, ByVal Language As String)
  125.   ml_ChangeLanguage LanguageID, Language
  126.   ml_UpdateControls
  127. End Sub
  128. Private Sub Form_Load()
  129.   ml_UpdateControls
  130.   Set ml_RuntimeSupport = New MLSupport
  131. End Sub
  132. Private Sub ml_UpdateControls()
  133.   Me.Caption = ml_string(7)
  134.   chkShowOnStartup.Caption = ml_string(8)
  135.   OkButton.Caption = ml_string(9)
  136. End Sub
  137.