VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.UserControl listpicture 
   ClientHeight    =   2370
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   5760
   ControlContainer=   -1  'True
   ScaleHeight     =   2370
   ScaleWidth      =   5760
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   2160
      Top             =   1560
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   3
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "listpicture.ctx":0000
            Key             =   "lleno"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "listpicture.ctx":031A
            Key             =   "medio"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "listpicture.ctx":0634
            Key             =   "vacio"
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton cmd_quitartodos 
      Caption         =   "<<"
      Height          =   375
      Left            =   2400
      TabIndex        =   3
      Top             =   1920
      Width           =   855
   End
   Begin VB.CommandButton cmd_quitaritem 
      Caption         =   "<"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2400
      TabIndex        =   2
      Top             =   1320
      Width           =   855
   End
   Begin VB.CommandButton cmd_agregartodos 
      Caption         =   ">>"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2400
      TabIndex        =   1
      Top             =   720
      Width           =   855
   End
   Begin VB.CommandButton cmd_agregaritem 
      Caption         =   ">"
      Height          =   375
      Left            =   2400
      TabIndex        =   0
      Top             =   120
      Width           =   855
   End
   Begin MSComctlLib.ListView lst_sel 
      Height          =   2295
      Left            =   3360
      TabIndex        =   4
      Top             =   0
      Width           =   2295
      _ExtentX        =   4048
      _ExtentY        =   4048
      View            =   1
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   393217
      Icons           =   "ImageList1"
      SmallIcons      =   "ImageList1"
      ColHdrIcons     =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
   Begin MSComctlLib.ListView lst_disp 
      Height          =   2295
      Left            =   20
      TabIndex        =   5
      Top             =   0
      Width           =   2295
      _ExtentX        =   4048
      _ExtentY        =   4048
      Arrange         =   2
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   0   'False
      HideSelection   =   -1  'True
      _Version        =   393217
      Icons           =   "ImageList1"
      SmallIcons      =   "ImageList1"
      ColHdrIcons     =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
End
Attribute VB_Name = "listpicture"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'control picture_list
'autor  : gustavo duffoo
'fecha:  20/10/2002 10:00 am
'necesite como minimo un recordset
'tomas los tres primeros campos del recorset para llenar las listas
' el primer campo debe ser la descripciom
'el segundo campo debe ser el ID
' el tercer campo debe ser un numero para el icono que se mostrara
'este control fue construido a partir del control lista

Private Sub cmd_agregaritem_Click()
Dim llon_nl As Long
Dim ITMX As ListItem
Dim lstr_cadena As String
Dim lstr_ICONO As String
If lst_disp.ListItems.Count = 0 Then
    Exit Sub
End If
llon_nl = lst_disp.SelectedItem.Index
lstr_cadena = lst_disp.SelectedItem.Text
lstr_ICONO = lst_disp.SelectedItem.Icon
Set ITMX = lst_sel.ListItems.Add(, , lstr_cadena, lstr_ICONO, lstr_ICONO)
lst_disp.ListItems.Remove (llon_nl)
lst_disp.Sorted = True

If lst_disp.ListItems.Count > 1 Then
   If llon_nl = 1 Then
      lst_disp.ListItems.Item(llon_nl).Selected = True
   Else
      lst_disp.ListItems.Item(llon_nl - 1).Selected = True
   End If
End If

End Sub

Private Sub cmd_agregartodos_Click()
Dim llon_nl As Long
Dim llon_nele As Long
Dim ITMX As ListItem
Dim lstr_cadena As String
Dim lstr_ICONO As String
llon_nele = lst_disp.ListItems.Count
If llon_nele = 0 Then
    Exit Sub
End If
For llon_nl = 1 To llon_nele ' Step -1
    lstr_cadena = lst_disp.ListItems(llon_nl).Text
    lstr_ICONO = lst_disp.ListItems(llon_nl).Icon
    Set ITMX = lst_sel.ListItems.Add(, , lstr_cadena, lstr_ICONO, lstr_ICONO)
    'lst_disp.ListItems.Remove (llon_nl)
Next
    lst_disp.Sorted = True
    lst_disp.ListItems.Clear
End Sub
Private Sub cmd_quitaritem_Click()
Dim llon_nl As Long
Dim ITMX As ListItem
Dim lstr_cadena As String
Dim lstr_ICONO As String
If lst_sel.ListItems.Count = 0 Then
    Exit Sub
End If
llon_nl = lst_sel.SelectedItem.Index
lstr_cadena = lst_sel.SelectedItem.Text
lstr_ICONO = lst_sel.SelectedItem.Icon
Set ITMX = lst_disp.ListItems.Add(, , lstr_cadena, lstr_ICONO, lstr_ICONO)
lst_sel.ListItems.Remove (llon_nl)
lst_sel.Sorted = True
If lst_sel.ListItems.Count > 1 Then
   If llon_nl = 1 Then
      lst_sel.ListItems.Item(llon_nl).Selected = True
   Else
      lst_sel.ListItems.Item(llon_nl - 1).Selected = True
   End If
End If
End Sub

Private Sub cmd_quitartodos_Click()
Dim llon_nl As Long
Dim llon_nele  As Long
Dim ITMX As ListItem
Dim lstr_cadena As String
Dim lstr_ICONO As String

llon_nele = lst_sel.ListItems.Count
If llon_nele = 0 Then
    Exit Sub
End If
For llon_nl = 1 To llon_nele
    lstr_cadena = lst_sel.ListItems(llon_nl).Text
    lstr_ICONO = lst_sel.ListItems(llon_nl).Icon
    Set ITMX = lst_disp.ListItems.Add(, , lstr_cadena, lstr_ICONO, lstr_ICONO)
Next
lst_sel.ListItems.Clear
lst_sel.Sorted = True
End Sub
Private Sub lst_disp_DblClick()
cmd_agregaritem_Click
End Sub

Private Sub lst_sel_DblClick()
cmd_quitaritem_Click
End Sub

Public Function listar_codigos_disponibles() As String
Dim i As Integer
Dim lint_ne As Integer 'numero de elementos
Dim lstr_cadena As String
Dim lstr_temp As String
lint_ne = lst_disp.ListItems.Count
For i = 1 To lint_ne
    lstr_temp = lst_disp.ListItems(i).Text
    If i > 1 Then lstr_cadena = lstr_cadena + ","
    lstr_cadena = lstr_cadena + "'" + Trim(Mid(lstr_temp, InStr(lstr_temp, "=") + 1)) + "'"
Next
listar_codigos_disponibles = lstr_cadena
End Function

Public Function listar_codigos_seleccionados() As String
'se agrego por compatibilidad
'realiza la misma funcion que listar_codigos
Dim i As Integer
Dim lint_ne As Integer 'numero de elementos
Dim lstr_cadena As String
Dim lstr_temp As String
lint_ne = lst_sel.ListItems.Count
For i = 1 To lint_ne
    lstr_temp = lst_sel.ListItems(i).Text
    If i > 1 Then lstr_cadena = lstr_cadena + ","
    lstr_cadena = lstr_cadena + "'" + Trim(Mid(lstr_temp, InStr(lstr_temp, "=") + 1)) + "'"
Next
listar_codigos_seleccionados = lstr_cadena
End Function
Public Function nseleccionados() As Integer
nseleccionados = lst_sel.ListItems.Count
End Function
Public Function ndisponibles() As Integer
ndisponibles = lst_disp.ListItems.Count
End Function
Public Sub size(filas As Integer, Optional COLUMNAS As Integer)
lst_disp.Height = filas * 180
lst_sel.Height = filas * 180
If COLUMNAS > 0 Then
    lst_disp.Width = COLUMNAS * 90
    
    cmd_agregaritem.Left = lst_disp.Width + 150
    cmd_agregartodos.Left = lst_disp.Width + 150
    cmd_quitaritem.Left = lst_disp.Width + 150
    cmd_quitartodos.Left = lst_disp.Width + 150
    lst_sel.Left = lst_disp.Width + cmd_agregaritem.Width + 300
    lst_sel.Width = COLUMNAS * 90
    
End If
End Sub

Public Sub llena_lista(ByVal rs As ADODB.Recordset, Optional rs2 As ADODB.Recordset)
Dim ITMX As ListItem
Dim lstr_cadena As String
Dim lstr_ICONO As String
Dim lint_tipo As Integer

lst_disp.View = lvwSmallIcon
lst_sel.View = lvwSmallIcon

lst_sel.ListItems.Clear
lst_disp.ListItems.Clear

If Not rs Is Nothing Then
    If rs.RecordCount > 0 Then
        rs.MoveFirst
        Do While Not rs.EOF
            lstr_cadena = rs.Fields(1) + Space(50) + "=" + rs.Fields(0)
            lint_tipo = rs.Fields(2)
            If lint_tipo = 0 Then
                    lstr_ICONO = "lleno"
            Else
                    lstr_ICONO = "medio"
            End If
            Set ITMX = lst_disp.ListItems.Add(, , lstr_cadena, lstr_ICONO, lstr_ICONO)
            lst_disp.Sorted = True
            rs.MoveNext
        Loop
    End If
End If
If rs2 Is Nothing Then      'llego solo un rs, se llena todo el list disponibles
    ' y solo se llenan en disponibles los que no esten en sel
Else
    If rs2.RecordCount > 0 Then
        rs2.MoveFirst
        Do While Not rs2.EOF
            lstr_cadena = rs2.Fields(1) + Space(50) + "=" + rs2.Fields(0)
            lint_tipo = rs2.Fields(2)
            If lint_tipo = 0 Then
                    lstr_ICONO = "lleno"
            Else
                   lstr_ICONO = "medio"
            End If
            Set ITMX = lst_sel.ListItems.Add(, , lstr_cadena, lstr_ICONO, lstr_ICONO)
            lst_sel.Sorted = True
            rs2.MoveNext
         Loop
    
    End If
End If
End Sub
Private Sub UserControl_Initialize()
lst_disp.View = lvwSmallIcon
lst_sel.View = lvwSmallIcon
End Sub
