Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/09/2008, 07:28
lucho81
 
Fecha de Ingreso: septiembre-2008
Mensajes: 13
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: relacionar imagnes con uan bd en accses

este es el codigo del formulario, es lo unico que tengo. La bd esta coenctada con el adodb.conection

'Declaración del Api GetFileTitle
Private Declare Function GetFileTitle _
Lib "comdlg32.dll" _
Alias "GetFileTitleA" ( _
ByVal lpszFile As String, _
ByVal lpszTitle As String, _
ByVal cbBuf As Integer) As Integer

Private Function Obtener_Nombre_Archivo(p As String)
Dim Buffer As String
'Buffer de caracteres
Buffer = String(255, 0)
'Llamada a GetFileTitle, pasandole el path, el buffer y el tamaño
GetFileTitle p, Buffer, Len(Buffer)

'Retornamos el nombre eliminando los espacios nulos
Obtener_Nombre_Archivo = Left$(Buffer, InStr(1, Buffer, Chr$(0)) - 1)
End Function

'------------------------------------------------
' Carga los gráficos del FileList en el ListView
'------------------------------------------------
Sub Cargar_Imagen( _
ListView As ListView, _
imageList As imageList, _
progressbar As progressbar)

On Local Error GoTo errSub

Dim Imagen As Integer, Clave As String

Set ListView.Icons = Nothing

With imageList
'Elimina las imágenes del ImageList
.ListImages.Clear
'Elimina los Items del Listview
ListView.ListItems.Clear
End With

'Según el optionbutton seleccionado, asigna el ancho y alto _
que tendrá la imagen cargada en en el Listview
With imageList
If Option1(0) Then
.ImageHeight = 16
.ImageWidth = 16
ElseIf Option1(1) Then
.ImageHeight = 32
.ImageWidth = 32
ElseIf Option1(2) Then
.ImageHeight = 48
.ImageWidth = 48
ElseIf Option1(3) Then
.ImageHeight = 64
.ImageWidth = 64
ElseIf Option1(4) Then
.ImageHeight = 128
.ImageWidth = 128
End If
End With

With progressbar
.Value = 0
.Max = File1.ListCount
End With

' Recorre el FileListBox con las imagenes para agregar
For Imagen = 0 To File1.ListCount - 1
'clave ( nombre del gráfico) para asignar al ImageList y el ListView
Clave = File1.List(Imagen)
'Agrega el gráfico al ImageListleyendo del disco con LaodPicture
imageList.ListImages.Add , Clave, _
LoadPicture(Dir1.Path & "\" & Clave)


' Si el ImageList no está inicializdo ..lo enlaza al Listview

If ListView.Icons Is Nothing Then
Set ListView.Icons = imageList
End If

'Agrega la imagen
ListView.ListItems.Add , , Clave, Clave

'Visualiza el progreso
progressbar.Value = Imagen + 1
DoEvents

Next

progressbar.Value = 0

Exit Sub
'Error
errSub:
MsgBox " Número de Error:" & Err.Number & vbNewLine _
& Err.Description, vbCritical

End Sub

Private Sub Dir1_Change()
File1 = Dir1

If File1.ListCount = 0 Then
Exit Sub
Else
' Carga el Listview si es que hay imagenes
Call Cargar_Imagen(ListView1, ImageList1, ProgressBar1)
Me.Caption = Dir1.Path
End If
End Sub

Private Sub Drive1_Change()
Dir1 = Drive1
End Sub

Private Sub Form_Load()
Dim X As String

' Filtro de extensiones para los archivos del FileList
File1.Pattern = "*.jpg;*.jpeg"
Option1(2).Value = True
With ListView1
' Tipo de ordenación de los íconos
ListView1.Arrange = lvwAutoTop
End With
Option1(1).Value = True
Option1(0).Caption = "16 * 16 pixeles"
Option1(1).Caption = "32 * 32 pixeles"
Option1(2).Caption = "48 * 48 pixeles"
Option1(3).Caption = "64 * 64 pixeles"
Option1(4).Caption = "128 * 128 pixeles"
ImgTem
Set cmd = New ADODB.Command
Set rsimgMatch = New ADODB.Recordset

With cmd
.ActiveConnection = base
.CommandText = "select * FROM ImgTem"
.CommandType = adCmdText
.Parameters.Refresh
End With
rsimgMatch.Open cmd, , adOpenDynamic, adLockOptimistic
Set DtgImgTemp.DataSource = rsimgMatch
End Sub