ImageList & Treevie

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Stanton

    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.Ima geListCtrl.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.I mageWidth = 16
    ImList.Object.I mageHeight = 16

    Set MyDb = CurrentDb()
    Set IconTable = MyDb.OpenRecord set(IconTableNa me, 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.ListI mages.Add(!Icon No + 1, !IconName, _
    LoadPicture(CoI conPath & "\" & !IconName & ".ico"))
    'StoredIcon.Pic ture = 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.Pict ure = 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


Working...