I 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(Cance l As Integer)
Call ImageList_Initi alize(ImList)
Call ImageList_Fill( ImList, "Icons")
End Sub
............... ............... ............... ..............
Function ImageList_Initi alize(ByVal ImageList As Object)
On Error GoTo ImageList_Initi alize_Error
ImageList.ListI mages.Clear
ImageList_Initi alize_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.I mageWidth = 16
ImList.Object.I mageHeight = 16
'* DAO-Variablen initialisieren
Set MyDb = CurrentDb()
Set IconTable = MyDb.OpenRecord set(IconTableNa me, dbOpenDynaset)
'* Wenn kein Datensatz vorhanden, dann Abbruch!
If IconTable.Recor dCount = 0 Then GoTo ImageList_Fill_ Exit
IconTable.MoveF irst
While Not IconTable.EOF
'* kleine Images in ImageList einfügen
Set img = ImageList.ListI mages.Add(IconT able![IconNo] + 1,
IconTable![IconName], _
LoadPicture(CoI conPath & "\" & IconTable![IconName] & ".ico"))
IconTable.MoveN ext
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
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(Cance l As Integer)
Call ImageList_Initi alize(ImList)
Call ImageList_Fill( ImList, "Icons")
End Sub
............... ............... ............... ..............
Function ImageList_Initi alize(ByVal ImageList As Object)
On Error GoTo ImageList_Initi alize_Error
ImageList.ListI mages.Clear
ImageList_Initi alize_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.I mageWidth = 16
ImList.Object.I mageHeight = 16
'* DAO-Variablen initialisieren
Set MyDb = CurrentDb()
Set IconTable = MyDb.OpenRecord set(IconTableNa me, dbOpenDynaset)
'* Wenn kein Datensatz vorhanden, dann Abbruch!
If IconTable.Recor dCount = 0 Then GoTo ImageList_Fill_ Exit
IconTable.MoveF irst
While Not IconTable.EOF
'* kleine Images in ImageList einfügen
Set img = ImageList.ListI mages.Add(IconT able![IconNo] + 1,
IconTable![IconName], _
LoadPicture(CoI conPath & "\" & IconTable![IconName] & ".ico"))
IconTable.MoveN ext
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