Help with Image List control
am 15.04.2008 23:59:55 von Phil StantonI am using an imageList control for a tree menu. Works fine
Problem I have is using VB to populate the ImageList
Basically I have a table of Icons that I wish to use. They point to a folder
where I store the Icon images. The name of the ImageList is ImList.
The LoadPicture routine finds the full path of the Icon, and obviously I
want to store these icons in the ImList. No problem doing it manually with
the form in design view, but this is not something that a user has access to
I don't speak German so that has not helped. Can't remember where I copied
the code from
The code is
Private Sub Form_Open(Cancel As Integer)
Call ImageList_Initialize(ImList)
Call ImageList_Fill(ImList, "Icons")
End Sub
...........................................................
Function ImageList_Initialize(ByVal ImageList As Object)
On Error GoTo ImageList_Initialize_Error
ImageList.ListImages.Clear
ImageList_Initialize_Error:
If Err Then MsgBox Err.Description, vbCritical, "No." & Err.Number
End Function
............................................................ ......
Function ImageList_Fill(ByVal ImageList As Object, ByVal IconTableName As
String) As Boolean
On Error GoTo ImageList_Fill_Error
'* ImageList-Variablen definieren
Dim img As ListImage
'* DAO-Variablen definieren
Dim MyDb As Database
Dim IconTable As Recordset
'* Funktion initialisieren
ImageList_Fill = False
ImList.Object.ImageWidth = 16
ImList.Object.ImageHeight = 16
'* DAO-Variablen initialisieren
Set MyDb = CurrentDb()
Set IconTable = MyDb.OpenRecordset(IconTableName, dbOpenDynaset)
'* Wenn kein Datensatz vorhanden, dann Abbruch!
If IconTable.RecordCount = 0 Then GoTo ImageList_Fill_Exit
IconTable.MoveFirst
While Not IconTable.EOF
'* kleine Images in ImageList einfügen
Set img = ImageList.ListImages.Add(IconTable![IconNo] + 1,
IconTable![IconName], _
LoadPicture(CoIconPath & "\" & IconTable![IconName] & ".ico"))
IconTable.MoveNext
Wend
'* Funktion erfolgreich!
ImageList_Fill = True
ImageList_Fill_Exit:
'* DAO-Variablen schliessen
IconTable.Clone
MyDb.Close
'* DAO-Variablen terminieren
Set IconTable = Nothing
Set MyDb = Nothing
ImageList_Fill_Error:
If Err Then MsgBox Err.Description, vbCritical, "No." & Err.Number
End Function
.......................
What am I missing
Thanks
Phil