VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.UserControl ToolBr 
   Alignable       =   -1  'True
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   ClientHeight    =   675
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   7680
   ScaleHeight     =   675
   ScaleWidth      =   7680
   ToolboxBitmap   =   "ToolBr.ctx":0000
   Begin MSComctlLib.ImageCombo imgcombo 
      Height          =   330
      Left            =   4920
      TabIndex        =   0
      Top             =   60
      Width           =   855
      _ExtentX        =   1508
      _ExtentY        =   582
      _Version        =   393216
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
   End
   Begin MSComctlLib.ImageList imgflag 
      Left            =   600
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      MaskColor       =   12632256
      _Version        =   393216
   End
   Begin VB.Image pic 
      Height          =   480
      Index           =   0
      Left            =   2040
      Top             =   60
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "ToolBr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

Option Explicit

' ATTENTION : la propriété du composant Flag doit être laissée à True.
'en conception cela donne le drapeau anglais mais pas en éxécution.
'Si on modifie cette propriété à false on récupère un bug d'affichage :
'le premier appui sur le composant génère un ascenseur vertical dans la ComboImage des drapeaux.
'
Private m_Language As String
Private mb_Horizontal As Boolean
Private mb_LanguageChange As Boolean
Private ms_PictureDisplayed As String
Private mb_FlagChange As Boolean

Public DrivenByCapture As Boolean

' Save maintenance icons and position in case of translation
Private mi_Add As Integer
Private mi_Upd As Integer
Private mi_Del As Integer
Private mb_Add As Boolean
Private mb_Upd As Boolean
Private mb_Del As Boolean

' Automatic Icons from table Security and connection parameters
Private ms_TableName As String
Private ms_ConnectString As String
Private ms_UID As String

Private mo_ArmDb As Object
Private mb_Created As Boolean
Private mb_use_framework_connection As Boolean

Private ms_LangAuthorized

Private mo_Icons As Collection

Private mb_Enabled As Boolean

Public Enum IconBox_Picture
    P_Add = 101
    P_Update = 102
    P_Delete = 103
    P_Find = 104
    P_Print = 105
    P_Audit = 106
    P_Refresh = 107
    P_Media = 108
    P_Language = 109
    P_Sort = 110
    P_Excel = 111
    P_Memo = 112
    P_ToolBox = 113
    P_Copy = 114
    P_UnDo = 115
    P_Execute = 116
    P_Save = 117
    P_Restore = 118
    P_New = 119
    P_And = 120
    P_Union = 121
    P_OpEQ = 122
    P_OpGE = 123
    P_OpLE = 124
    P_OpGT = 125
    P_OpLT = 126
    P_OpNE = 127
    P_OpLIKE = 128
    P_Valid = 129
    P_View = 130
    P_Help = 131
    P_Quit = 132
    P_Compute = 133
    P_Previous = 141
    P_Next = 142
    P_Patent = 143
End Enum

Public Event action(ByVal as_ActionType As String)
Public Event flag(ByVal as_Flag As String)

Private Const KEY_PREF = "Key_"
Private Const MAX_ICON = 43
'Database Access
Dim ordre(MAX_ICON) As String
Dim nb_icons_created As Integer
Dim li_index_maxi As Integer

Public Property Set ArmDb(ByRef ao_framework_connection As Object)
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:ArmDb_Set"
    #End If
    If Not (ao_framework_connection Is Nothing) Then
        Set mo_ArmDb = ao_framework_connection
        mb_use_framework_connection = True
    End If
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:ArmDb_Set"
    #End If
End Property

Public Property Let ConnectString(as_ConnectString As String)
    
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:ConnectString_Let", "as_ConnectString=" & as_ConnectString
    #End If
    ms_UID = ConnectionStringValidation(as_ConnectString)
    If ms_UID = "" Then GoTo Trace_End
    
    ms_ConnectString = as_ConnectString
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:ConnectString_Let"
    #End If
End Property

Public Property Let Enabled(ab_Enabled As Boolean)
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Enabled_Let", "ab_enabled=" & ab_Enabled
    #End If
    mb_Enabled = ab_Enabled
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Enabled_Let"
    #End If
End Property

Private Function IsLoaded(li_Index As IconBox_Picture) As Boolean
Dim i As Integer
Dim Found As Boolean

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:IsLoaded", "li_Index=" & li_Index
    #End If
    
    i = 1
    Found = False
    While i <= mo_Icons.Count And Not Found
        If CInt(mo_Icons.Item(i).Tag) = li_Index Then
            Found = True
        End If
        i = i + 1
    Wend

    IsLoaded = Found

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:IsLoaded", "Result=" & IsLoaded
    #End If
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:IsLoaded"
End Function

Public Property Get PictureDisplayed() As String
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:PictureDisplayed_Get"
    #End If
    PictureDisplayed = ms_PictureDisplayed
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:PictureDisplayed_Get", "Result=" & PictureDisplayed
    #End If
End Property

Public Property Get icons_count() As String
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:icons_count_Get"
    #End If
    icons_count = nb_icons_created
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:icons_count_Get", "Result=" & icons_count
    #End If
End Property

Public Property Let PictureDisplayed(as_PictureDisplayed As String)
    
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:PictureDisplayed_Let", "as_PictureDisplayed=" & as_PictureDisplayed
    #End If
    ms_PictureDisplayed = as_PictureDisplayed
    
    Refresh
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:PictureDisplayed_Let"
    #End If
End Property

Public Property Get FlagChange() As Boolean
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:FlagChange_Get"
    #End If
    FlagChange = mb_FlagChange
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:FlagChange_Get", "Result=" & FlagChange
    #End If
End Property

Public Property Let FlagChange(ab_FlagChange As Boolean)
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:FlagChange_Let", "ab_FlagChange=" & ab_FlagChange
    #End If
    mb_FlagChange = ab_FlagChange
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:FlagChange_Let"
    #End If
End Property

Public Property Get LanguageChange() As Boolean
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:LanguageChange_Get"
    #End If
    LanguageChange = mb_LanguageChange
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:LanguageChange_Get", "Result=" & LanguageChange
    #End If
End Property

Public Property Let LanguageChange(ab_LanguageChange As Boolean)
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:LanguageChange_Let", "ab_LanguageChange=" & ab_LanguageChange
    #End If
    mb_LanguageChange = ab_LanguageChange
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:LanguageChange_Let"
    #End If
End Property

Private Sub DrawLanguage(li_Language As Integer)

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:DrawLanguage", "li_Language=" & li_Language
    #End If
    
    If mb_Horizontal Then
        imgcombo.Left = 60 + (li_Language - 1) * 600
        If li_Language < 0 Then
            imgcombo.Left = Width + li_Language * 600
        End If
        imgcombo.Top = 60
    Else
        imgcombo.Top = 60 + (li_Language - 1) * 600
        If li_Language < 0 Then
            imgcombo.Top = Height + li_Language * 600
        End If
        imgcombo.Left = 60
    End If
    
    imgcombo.Visible = False

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:DrawLanguage"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:DrawLanguage"
End Sub

Public Property Get Language() As String
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Language_Get"
    #End If
    Language = m_Language
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Language_Get", "Result=" & Language
    #End If
End Property

Public Property Let Language(as_Language As String)
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Language_Let", "as_Language=" & as_Language
    #End If
    m_Language = as_Language
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Language_Let"
    #End If
End Property

Public Property Let TableName(as_tableName As String)
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:TableName_Let", "as_TableName=" & as_tableName
    #End If
    ms_TableName = as_tableName
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:TableName_Let"
    #End If
End Property

Public Property Get TableName() As String
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:TableName_Get"
    #End If
    TableName = ms_TableName
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:TableName_Get", "Result=" & TableName
    #End If
End Property

Private Sub imgcombo_LostFocus()
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:imgcombo_LostFocus"
    #End If
    imgcombo.Visible = 0
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:imgcombo_LostFocus"
    #End If
End Sub

Public Sub Load_A_Com()
    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Load_A_Com"
    #End If
    
    VerifyInitialization mo_ArmDb, ms_ConnectString, m_Language, Me
    
    Set mo_Icons = New Collection

    ordre(1) = "Add"
    ordre(2) = "Update"
    ordre(3) = "Delete"
    ordre(4) = "Find"
    ordre(5) = "Print"
    ordre(6) = "Audit"
    ordre(7) = "Refresh"
    ordre(8) = "Media"
    ordre(9) = "Language"
    ordre(10) = "Sort"
    ordre(11) = "Excel"
    ordre(12) = "Memo"
    ordre(13) = "Tool"
    ordre(14) = "Copy"
    ordre(15) = "Undo"
    ordre(16) = "Execute"
    ordre(17) = "Save"
    ordre(18) = "Restore"
    ordre(19) = "New"
    ordre(20) = "And"
    ordre(21) = "Union"
    ordre(22) = "OpEQ"
    ordre(23) = "OpGE"
    ordre(24) = "OpLE"
    ordre(25) = "OpGT"
    ordre(26) = "OpLT"
    ordre(27) = "OpNE"
    ordre(28) = "OpLike"
    ordre(29) = "Valid"
    ordre(30) = "View"
    ordre(31) = "Help"
    ordre(32) = "Quit"
    ordre(33) = "Compute"
    ordre(34) = "G"
    ordre(35) = "S"
    ordre(36) = "F"
    ordre(37) = "E"
    ordre(38) = "I"
    ordre(39) = "D"
    ordre(40) = "R"
    ordre(41) = "Previous"
    ordre(42) = "Next"
    ordre(43) = "Patent"

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Load_A_Com"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:Load_A_Com"
End Sub

Private Sub UserControl_InitProperties()

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:UserControl_InitProperties"
    #End If
    
    mb_LanguageChange = True
    m_Language = "E"
    imgcombo.Top = -150
    imgcombo.Left = 0
    ms_PictureDisplayed = ""
    DrawIcons ms_PictureDisplayed

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:UserControl_InitProperties"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:UserControl_InitProperties"
End Sub

Private Sub pic_Click(ai_index As Integer)
Dim li_Index As Integer

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:pic_Click", "ai_index=" & ai_index
    #End If
    UserControl.Enabled = False
    
    If ai_index > 100 And ai_index < 200 Then li_Index = ai_index - 100 Else li_Index = ai_index
    
    If mb_Enabled = False Then GoTo Trace_End
    
    RaiseEvent action(ordre(li_Index))

    If ordre(li_Index) = "Language" Then
        If imgcombo.ComboItems.Count = 0 Then
            LoadFlag
        End If
    End If
    
Trace_End:
    UserControl.Enabled = True
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:pic_Click"
    #End If
    Exit Sub
    
Trace_Err:
    UserControl.Enabled = True
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:pic_Click"
End Sub

Private Sub DrawIcons(as_PictureDisplayed As String)
Dim ls_Array() As String
Dim ls_Cell As String
Dim ls_Icon As String
Dim li_Position As Integer
Dim i As Integer

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:DrawIcons", "as_PictureDisplayed=" & as_PictureDisplayed
    #End If
    
    mb_Add = False
    mb_Upd = False
    mb_Del = False
    mi_Add = 0
    mi_Upd = 0
    mi_Del = 0
    
    ls_Array = Split(as_PictureDisplayed, " ", -1)

    For i = 0 To UBound(ls_Array)
    
        ls_Cell = ls_Array(i)
        If ls_Cell <> "" Then
            li_Position = Mid(ls_Cell, InStr(1, ls_Cell, "=") + 1)
            ls_Icon = Mid(ls_Cell, 1, InStr(1, ls_Cell, "=") - 1)
        
            Select Case UCase$(ls_Icon)
                ' the rank of 5 firsts is very important for automatic security
                Case UCase$("P_Add"):
                    DrawIcon P_Add, li_Position
                    mb_Add = True
                    mi_Add = li_Position
                Case UCase$("P_Update"):
                    DrawIcon P_Update, li_Position
                    mb_Upd = True
                    mi_Upd = li_Position
                Case UCase$("P_Delete"):
                    DrawIcon P_Delete, li_Position
                    mb_Del = True
                    mi_Del = li_Position
                Case UCase$("P_Memo"):
                    DrawIcon P_Memo, li_Position
                Case UCase$("P_Language"):
                    DrawIcon P_Language, li_Position
                    DrawLanguage li_Position
                    
                Case UCase$("P_Find"):
                    DrawIcon P_Find, li_Position
                Case UCase$("P_Print"):
                    DrawIcon P_Print, li_Position
                Case UCase$("P_Audit"):
                    DrawIcon P_Audit, li_Position
                Case UCase$("P_Refresh"):
                    DrawIcon P_Refresh, li_Position
                Case UCase$("P_Media"):
                    DrawIcon P_Media, li_Position
                Case UCase$("P_Sort"):
                    DrawIcon P_Sort, li_Position
                Case UCase$("P_Excel"):
                    DrawIcon P_Excel, li_Position
                Case UCase$("P_ToolBox"):
                    DrawIcon P_ToolBox, li_Position
                Case UCase$("P_Copy"):
                    DrawIcon P_Copy, li_Position
                Case UCase$("P_UnDo"):
                    DrawIcon P_UnDo, li_Position
                Case UCase$("P_Execute"):
                    DrawIcon P_Execute, li_Position
                Case UCase$("P_Save"):
                    DrawIcon P_Save, li_Position
                Case UCase$("P_Restore"):
                    DrawIcon P_Restore, li_Position
                Case UCase$("P_New"):
                    DrawIcon P_New, li_Position
                Case UCase$("P_And"):
                    DrawIcon P_And, li_Position
                Case UCase$("P_Union"):
                    DrawIcon P_And, li_Position
                Case UCase$("P_OpEQ"):
                    DrawIcon P_OpEQ, li_Position
                Case UCase$("P_OpGE"):
                    DrawIcon P_OpGE, li_Position
                Case UCase$("P_OpLE"):
                    DrawIcon P_OpLE, li_Position
                Case UCase$("P_OpGT"):
                    DrawIcon P_OpGT, li_Position
                Case UCase$("P_OpLT"):
                    DrawIcon P_OpLT, li_Position
                Case UCase$("P_OpNE"):
                    DrawIcon P_OpNE, li_Position
                Case UCase$("P_OpLIKE"):
                    DrawIcon P_OpLIKE, li_Position
                Case UCase$("P_Valid"):
                    DrawIcon P_Valid, li_Position
                Case UCase$("P_View"):
                    DrawIcon P_View, li_Position
                Case UCase$("P_Help"):
                    DrawIcon P_Help, li_Position
                Case UCase$("P_Quit"):
                    DrawIcon P_Quit, li_Position
                Case UCase$("P_Compute"):
                    DrawIcon P_Compute, li_Position
                Case UCase$("P_Previous"):
                    DrawIcon P_Previous, li_Position
                Case UCase$("P_Next"):
                    DrawIcon P_Next, li_Position
                Case UCase$("P_Patent"):
                    DrawIcon P_Patent, li_Position
            End Select
        End If
    Next i

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:DrawIcons"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:DrawIcons"
End Sub

Public Sub ClearAllIcons()
Dim i As Integer

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:ClearAllIcons"
    #End If
    

    For i = 0 To MAX_ICON
        DeleteIcon i + 100
    Next
    
    li_index_maxi = 0
    imgcombo.Visible = False
    
    Set mo_Icons = Nothing
    Set mo_Icons = New Collection
    
    ms_TableName = ""
    ms_PictureDisplayed = ""
    
    Refresh
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:ClearAllIcons"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:ClearAllIcons"
End Sub

Private Sub DeleteIcon(ai_index As IconBox_Picture)

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:DeleteIcon", "ai_index=" & ai_index
    #End If
    
    If mo_Icons.Count > 0 Then
        If IsLoaded(ai_index) Then
            mo_Icons.Remove KEY_PREF & CStr(ai_index)
            Set pic(ai_index).Picture = Nothing
            Unload pic(ai_index)
        End If
    End If
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:DeleteIcon"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:DeleteIcon"
End Sub

Private Sub DrawIcon(let_IconBox As IconBox_Picture, Optional li_Tag)
Dim lo_Picture As Image
Dim li_Tag2 As Integer

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:DrawIcon", "let_IconBox=" & let_IconBox, "li_Tag=" & IIf(IsMissing(li_Tag), "", li_Tag)
    #End If
    
    If li_Tag = 0 Then
        DeleteIcon let_IconBox
    Else
        CreateIcon let_IconBox
      
        Set lo_Picture = mo_Icons(KEY_PREF & CStr(let_IconBox))
        
        
        If mb_Horizontal Then
            lo_Picture.Left = 60 + (li_Tag - 1) * 600
            If li_Tag < 0 Then
                lo_Picture.Left = Width + li_Tag * 600
            End If
            lo_Picture.Top = 60
        Else
            lo_Picture.Top = 60 + (li_Tag - 1) * 600
            If li_Tag < 0 Then
                lo_Picture.Top = Height + li_Tag * 600
            End If
            lo_Picture.Left = 60
        End If
        
        lo_Picture.Refresh
        lo_Picture.Visible = True
        
    End If
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:DrawIcon"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:DrawIcon"
End Sub

Private Sub CreateIcon(li_Index As IconBox_Picture, Optional as_Key)
'l'index li index correspond au numéro d'ordre dans le tableau des pictures
Dim lo_Picture As Image
        
    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:CreateIcon", "li_Index=" & li_Index, "as_Key=" & IIf(IsMissing(as_Key), "", as_Key)
    #End If
    
    If Not IsLoaded(li_Index) Then
    
        Load pic(li_Index)
        Set lo_Picture = pic(li_Index)
        lo_Picture.Tag = li_Index
        lo_Picture.Picture = LoadResPicture(li_Index, vbResIcon)
        lo_Picture.Visible = True
        
        If li_Index > li_index_maxi Then
            li_index_maxi = li_Index
        End If
        
        mo_Icons.Add lo_Picture, KEY_PREF & CStr(li_Index)
        nb_icons_created = nb_icons_created + 1
        
    End If
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:CreateIcon"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:CreateIcon"
End Sub

Public Function Permissions() As String
Dim ll_HStmt As Long
Dim ls_Req As String
Dim ls_Action As String

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Permissions"
    #End If
    
    Static sPersmission As String
    
    If DrivenByCapture And sPersmission <> "" Then
       ' GoTo Trace_End
    Else
      sPersmission = ""
    End If
    sPersmission = ""

    If ms_TableName = "" Then GoTo Trace_End
    
    If Not ASC_ConnectToDB(mo_ArmDb, ms_ConnectString, mb_Created) Then GoTo Trace_End
    
    ls_Req = "Exec Cap_Check_Security '" & ms_TableName & "', '" & ms_UID & "'"
    Permissions = ""
    ms_LangAuthorized = ""
    
        ll_HStmt = mo_ArmDb.OpenSQL(ls_Req, -1)
        If ll_HStmt = 0 Then
            If Not go_Trace Is Nothing Then go_Trace.WriteTraceSQLError mo_ArmDb, "ToolBr:Permissions", "Request=" & ls_Req
            GoTo Trace_End
        End If
        While mo_ArmDb.EOF(ll_HStmt) = False
            ls_Action = LCase(mo_ArmDb.GetFields(ll_HStmt, "action"))
            
            Select Case ls_Action
                Case "insert": sPersmission = sPersmission & "P_Add=1 "
                Case "update": sPersmission = sPersmission & "P_Update=2 "
                Case "delete": sPersmission = sPersmission & "P_Delete=3 "
                Case "memo": sPersmission = sPersmission & "P_Memo=4 "
            End Select
            
            If Left(ls_Action, 3) = "99_" Then ms_LangAuthorized = ms_LangAuthorized & right(ls_Action, Len(ls_Action) - 3)
            
            mo_ArmDb.Next ll_HStmt
        Wend
    
Trace_End:
    Permissions = sPersmission
    mo_ArmDb.Close ll_HStmt
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Permissions", "Result=" & Permissions
    #End If
    Exit Function
    
Trace_Err:
    mo_ArmDb.Close ll_HStmt
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:Permissions"
End Function

Public Sub Refresh()
Dim ls_PictureToDisplay As String

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Refresh"
    #End If
    
    If Width > Height Then
        mb_Horizontal = True
        Height = 660
    Else
        mb_Horizontal = False
        Width = 660
    End If
    ls_PictureToDisplay = Permissions & ms_PictureDisplayed
    DrawIcons ls_PictureToDisplay
    mb_Enabled = True

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Refresh"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:Refresh"
End Sub

Private Sub imgcombo_Click()
Dim li_Position As Integer
Dim ls_Flag As String

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:imgcombo_Click"
    #End If
    
    If imgcombo.ComboItems.Count = 0 Then LoadFlag
    
    If imgcombo.SelectedItem Is Nothing Then GoTo Trace_End
    If m_Language = imgcombo.SelectedItem.Key Then GoTo Trace_End
    
    ls_Flag = imgcombo.SelectedItem.Key
     
    Set pic(9).Picture = Nothing
    
    pic(9).Picture = LoadResPicture(Val(load_img_key(imgcombo.SelectedItem.Key)), vbResIcon)
    pic(9).Tag = imgcombo.SelectedItem.Key
    
    RaiseEvent flag(imgcombo.SelectedItem.Key)
    
    m_Language = ls_Flag
    
    If ls_Flag <> "E" Then
        'Hide add & delete icons on non english languages
        If mi_Add <> 0 Then pic(mi_Add).Visible = False
        If mi_Del <> 0 Then pic(mi_Del).Visible = False
        
        'Update icon available depending on rights in security table
        li_Position = InStr(1, UCase(ms_LangAuthorized), ls_Flag)
        If li_Position <> 0 Then
            If mi_Upd <> 0 And mb_Upd Then
                pic(mi_Upd).Visible = True
            End If
        Else
            If mi_Upd <> 0 Then pic(mi_Upd).Visible = False
        End If
    Else
        'Restore english parameters
        If mb_Add And mi_Add <> 0 Then
            pic(mi_Add).Visible = True
        End If
        If mb_Upd And mi_Upd <> 0 Then
            pic(mi_Upd).Visible = True
        End If
        If mb_Del And mi_Del <> 0 Then
            pic(mi_Del).Visible = True
        End If
    End If
    
    imgcombo.Visible = False
    imgcombo.ComboItems.Clear
    imgflag.ListImages.Clear

Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:imgcombo_Click"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:imgcombo_Click"
End Sub

Private Sub LoadFlag()
Dim z As Byte

    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:LoadFlag"
    #End If
    
    imgcombo.ComboItems.Clear
    imgflag.ListImages.Clear
    
    imgflag.ListImages.Add , "E", LoadResPicture(Val(load_img_key("E")), vbResIcon)
    imgflag.ListImages.Add , "D", LoadResPicture(Val(load_img_key("D")), vbResIcon)
    imgflag.ListImages.Add , "F", LoadResPicture(Val(load_img_key("F")), vbResIcon)
    imgflag.ListImages.Add , "G", LoadResPicture(Val(load_img_key("G")), vbResIcon)
    imgflag.ListImages.Add , "I", LoadResPicture(Val(load_img_key("I")), vbResIcon)
    imgflag.ListImages.Add , "R", LoadResPicture(Val(load_img_key("R")), vbResIcon)
    imgflag.ListImages.Add , "S", LoadResPicture(Val(load_img_key("S")), vbResIcon)
    
    Set imgcombo.ImageList = imgflag
    imgcombo.ComboItems.Clear
    Call imgcombo.ComboItems.Add(, "E", "", "E")         ' JN send parameter Text 21/05/2012
    Call imgcombo.ComboItems.Add(, "D", "", "D")
    Call imgcombo.ComboItems.Add(, "F", "", "F")
    Call imgcombo.ComboItems.Add(, "G", "", "G")
    Call imgcombo.ComboItems.Add(, "I", "", "I")
    Call imgcombo.ComboItems.Add(, "R", "", "R")
    Call imgcombo.ComboItems.Add(, "S", "", "S")
    
    
    For z = 1 To imgcombo.ComboItems.Count
        If imgcombo.ComboItems(z).Key = pic(9).Tag Then imgcombo.ComboItems(z).Selected = True
    Next z
    
    If imgcombo.SelectedItem Is Nothing Then imgcombo.ComboItems(1).Selected = True
    
    Set mo_Icons = Nothing
    Set mo_Icons = New Collection
    
    imgcombo.Visible = True
    imgcombo.SetFocus
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:LoadFlag"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:LoadFlag"
End Sub

Public Function load_img_key(ByVal cle As String) As String
Dim v As Integer
    
    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:load_img_key", "cle=" & cle
    #End If
    
    For v = 1 To 40
        If ordre(v) = cle Then
            load_img_key = v + 100
            v = 40
        End If
    Next v
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:load_img_key", "Result=" & load_img_key
    #End If
    Exit Function
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:load_img_key"
End Function

Public Sub Unload_A_Com()
    On Error GoTo Trace_Err
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc True, "ToolBr:Unload_A_COM"
    #End If
    
    Set mo_Icons = Nothing
    ASC_DisconnectFromDB mo_ArmDb, ms_UID, mb_Created
    
Trace_End:
    #If CompDebugToolBar Then
        If Not go_Trace Is Nothing Then go_Trace.WriteTraceProc False, "ToolBr:Unload_A_COM"
    #End If
    Exit Sub
    
Trace_Err:
    If Not go_Trace Is Nothing Then go_Trace.WriteTraceError Err.Number, Err.Description, "ToolBr:Unload_A_COM"
End Sub

