VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Trans_LangChoice 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Language choice"
   ClientHeight    =   2100
   ClientLeft      =   2280
   ClientTop       =   2325
   ClientWidth     =   3855
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2100
   ScaleWidth      =   3855
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame ToolBar 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   600
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   3855
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BorderStyle     =   0  'None
         DragIcon        =   "TRAN_LGC.frx":0000
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   600
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   3
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_Save 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "TRAN_LGC.frx":030A
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   2
         Top             =   60
         Width           =   480
      End
   End
   Begin MSComctlLib.ImageList img_pictList 
      Left            =   3240
      Top             =   720
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      MaskColor       =   8388736
      _Version        =   393216
   End
   Begin MSComctlLib.ListView lvw_Language 
      Height          =   1215
      Left            =   1500
      TabIndex        =   4
      Top             =   720
      Width           =   795
      _ExtentX        =   1402
      _ExtentY        =   2143
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      HideColumnHeaders=   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   0
      NumItems        =   1
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Object.Width           =   882
      EndProperty
   End
   Begin VB.Label lbl_Language 
      AutoSize        =   -1  'True
      BackColor       =   &H00C0C0C0&
      BackStyle       =   0  'Transparent
      Caption         =   " Language"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   240
      TabIndex        =   0
      Top             =   1200
      Width           =   1155
   End
End
Attribute VB_Name = "Trans_LangChoice"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'Private Sub csp_Language_DblClick()
'
'    If csp_Language.ListIndex <> -1 Then
'        pic_Save_Click
'    End If

'End Sub

Private Sub lvw_Language_DblClick()

    If Not lvw_Language.SelectedItem Is Nothing Then
        pic_Save_Click
    End If

End Sub

Private Sub Form_Load()
Dim ll_Statement As Long
Dim ls_Req As String
Dim li_Status As Integer
Dim lS_Code As String
Dim ls_Desc As String
Dim ls_Icon As String

    On Error GoTo suite
    
    MouseOff
    
    If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me
    
    'Load picture of the action button
    pic_Save.Picture = LoadResPicture(RES_OK, 1)
    pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
    
    ' NEW remove ListView begin
    Call InitImageList(img_pictList)
    Call InitListView(lvw_Language, img_pictList)
    ' NEW remove ListView end
    
    'Load all the language code available for this profile
    Select Case gut_Param2.Str1
    Case "Internet", "NewInternet"
        ls_Req = "EXEC TransIntSecurity_cbo '" & prg.LoginName & "'"
    Case "Glossary"
        ls_Req = "EXEC TransGloSecurity_cbo '" & prg.LoginName & "'"
    Case Else
        ls_Req = "EXEC TransSecurity_cbo '" & prg.LoginName & "'"
    End Select
    
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            lS_Code = ODBCData(ll_Statement, 1)
            ls_Desc = ODBCData(ll_Statement, 2)
            ls_Icon = ODBCData(ll_Statement, 3)
            Call InsertItem(lvw_Language, "_" & lS_Code, "", lS_Code & SEP & ls_Desc & SEP & ls_Icon, , ls_Icon, ls_Icon)
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    
    MouseOn
    Exit Sub
    
suite:

    Select Case Err
    Case 326
        'If the icon does'nt exist, we use a standard icon
        ls_Icon = "999"
        Resume
    Case Else
        'In other cases, we close the statement and inform the user
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        StdError
    End Select
    
End Sub


Private Sub pic_quit_Click()

    Unload Me

End Sub

Private Sub pic_Save_Click()

'    If csp_Language.ListIndex <> -1 Then
    If Not lvw_Language.SelectedItem Is Nothing Then
        
        MouseOff
        gut_LangWork.Code = GetTagValue(lvw_Language.SelectedItem, 0)
        gut_LangWork.Desc = GetTagValue(lvw_Language.SelectedItem, 1)
        gut_LangWork.Icon = GetTagValue(lvw_Language.SelectedItem, 2)
        
'        gut_LangWork.Code = csp_Language.ListTabText(csp_Language.ListIndex, 1)
'        gut_LangWork.Desc = csp_Language.ListTabText(csp_Language.ListIndex, 2)
'        gut_LangWork.Icon = csp_Language.ListTabText(csp_Language.ListIndex, 3)
        
        Select Case gut_Param2.Str1
        Case "Internet", "NewInternet"
            Trans_main.mb_ExportExcelEnabled = KO
        Case "Glossary"
            Trans_main.ms_ReqExportExcel = "EXEC glossary_t_lst '" & gut_LangWork.Code & "'"
            Trans_main.mb_ExportExcelEnabled = OK
        Case Else
            Trans_main.mb_ExportExcelEnabled = KO
        End Select
        Me.Hide
        MouseOn
                
        Trans_main.show 1
        
        Unload Me
    
    End If

End Sub

' NEW Remove ListView begin
Private Function InsertItem(ByVal ao_lvw As MSComctlLib.ListView, ByVal as_Key As String, ByVal as_Text As String, ByVal as_Tag As String, Optional ByVal ai_pos As Integer = -1, Optional ByVal al_icon As Long = -1, Optional ByVal al_smallIcon As Long = -1, Optional ByVal al_imageType As LoadResConstants = vbResIcon) As MSComctlLib.ListItem
    Dim lo_retItem As MSComctlLib.ListItem
    Set lo_retItem = GetItem(ao_lvw, as_Key)
    If lo_retItem Is Nothing Then
        Set lo_retItem = ao_lvw.ListItems.Add(IIf(ai_pos = -1, ao_lvw.ListItems.Count + 1, ai_pos), _
                                              as_Key, _
                                              as_Text, _
                                              GetImageIndex(ao_lvw.Icons, al_icon, al_imageType), _
                                              GetImageIndex(ao_lvw.SmallIcons, al_smallIcon, al_imageType))
        lo_retItem.Tag = as_Tag
    End If
    Set InsertItem = lo_retItem
End Function

Private Function GetTagValue(ByVal ao_lvw As MSComctlLib.ListItem, ByVal al_Index As Long)
    Dim ls_values() As String
    ls_values = Split(ao_lvw.Tag, SEP)

    GetTagValue = ls_values(al_Index)

End Function

Private Function GetItem(ByVal ao_lvw As MSComctlLib.ListView, ByVal as_Key As String) As MSComctlLib.ListItem
    Dim lo_retItem As MSComctlLib.ListItem
    
    Set GetItem = Nothing
    For Each lo_retItem In ao_lvw.ListItems
        If lo_retItem.Key = as_Key Then
            Set GetItem = lo_retItem
            Exit For
        End If
    Next
End Function

Private Function GetImageIndex(ByVal ao_imageList As MSComctlLib.ImageList, ByVal al_resIndex As Long, ByVal al_resType As LoadResConstants) As Variant
    If (ao_imageList Is Nothing) Or (al_resIndex = -1) Then
        GetImageIndex = Empty
        Exit Function
    End If
    
    Dim lo_image As MSComctlLib.ListImage
    For Each lo_image In ao_imageList.ListImages
        If lo_image.Key = "_" & al_resIndex Then
            GetImageIndex = lo_image.Index
            Exit Function
        End If
    Next
    
    GetImageIndex = LoadImage(ao_imageList, al_resIndex, al_resType)
End Function

Private Function LoadImage(ByVal ao_imageList As MSComctlLib.ImageList, ByVal al_resIndex As Long, ByVal al_resType As LoadResConstants) As Long
    Dim lo_image As MSComctlLib.ListImage
    Set lo_image = ao_imageList.ListImages.Add(, "_" & al_resIndex, LoadResPicture(al_resIndex, al_resType))
    LoadImage = lo_image.Index
End Function

Private Sub InitListView(ByRef ao_lvw As MSComctlLib.ListView, Optional ByVal ao_imgList As MSComctlLib.ImageList = Nothing)
    ao_lvw.HideSelection = False        ' don't hide selection when lostFocus
    ao_lvw.View = lvwReport
    ao_lvw.LabelEdit = lvwManual       ' disable edit labels
    ao_lvw.Icons = ao_imgList
    ao_lvw.SmallIcons = ao_imgList
End Sub

Private Sub InitImageList(ByRef ao_imgList As MSComctlLib.ImageList)
    ao_imgList.ImageHeight = 32
    ao_imgList.ImageWidth = 32
    ao_imgList.MaskColor = vbMagenta

    ' at least one image must be loaded to correctly initialize imagelist
    Call LoadImage(ao_imgList, RES_OPENFOLDER, vbResBitmap)
End Sub
' NEW Remove ListView end


