By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,611 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,611 IT Pros & Developers. It's quick & easy.

ImageList & Treevie

P: n/a
I am using a Treeview type menu sustem and need to load various icons

I have a form called Icons with a MSComctlLib.ImageListCtrl.2 control on it
called ImList

The IconTable holds IconNo and IconName

I use the following code OnOpen of the form which is supposed to load images
stored in a folder which is defined by CoIconPath

Function ImageList_Fill(ByVal ImageList As Object, ByVal IconTableName As
String) As Boolean

On Error GoTo ImageList_Fill_Error

Dim img As ListImage
Dim MyDb As Database
Dim IconTable As Recordset

'*initialise
ImageList_Fill = False

ImList.Object.ImageWidth = 16
ImList.Object.ImageHeight = 16

Set MyDb = CurrentDb()
Set IconTable = MyDb.OpenRecordset(IconTableName, dbOpenDynaset)
With IconTable

' If no icons specified - exit
If .RecordCount = 0 Then GoTo ImageList_Fill_Exit

.MoveFirst
While Not .EOF
' Add Image
Set img = ImageList.ListImages.Add(!IconNo + 1, !IconName, _
LoadPicture(CoIconPath & "\" & !IconName & ".ico"))
'StoredIcon.Picture = img.Picture
MsgBox "Image" & img.Index, vbOKOnly
.MoveNext
Wend

' Success
ImageList_Fill = True

ImageList_Fill_Exit:
.Close
Set IconTable = Nothing
End With

MyDb.Close

Set MyDb = Nothing

DoCmd.Save , Me.Name
Exit Function

ImageList_Fill_Error:
MsgBox Err.Description, vbCritical, "No." & Err.Number
Resume ImageList_Fill_Exit

End Function

The message box comes up 11 times, so I guess that the images are loaded. If
I go back to the form in design view, the InList control shows no images.
Why
How do I display what is held in this control.
If I uncomment out the line StoredIcon.Picture = img.Picture, I get an error
message "Microsoft Access can't open the file '55033946'. This file number
appears different every time

Any help please

Thanks

Phil
Oct 9 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.