469,272 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

ImageList & Treevie

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
0 2877

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bob C. | last post: by
4 posts views Thread by Just Me | last post: by
1 post views Thread by VBTricks.de.vu Webmaster | last post: by
6 posts views Thread by henrycortezwu | last post: by
1 post views Thread by John Devlon | last post: by
2 posts views Thread by =?Utf-8?B?S2VuTg==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.