Procedura:
Private Declare
Function ImageList_ReplaceIcon Lib _
"COMCTL32" (ByVal hImageList As Long, _
ByVal i As Long, ByVal hIcon As Long) As Long
'Nahraje sadu obrßzk∙ u
diskovΘho souboru do komponenty ImageList.
'Diskov² soubor musφ b²t p°edtφm ulo₧en pomocφ SaveImageList,
'a cφlov² ImageList musφ obsahovat dostatek obrßzk∙ v kolekci ListImage
Public Sub LoadImageList(ImageList
As ImageList, _
ByVal FileName As String)
Dim pb As New PropertyBag
Dim varTemp As Variant
Dim handle As Long
Dim Li As ListImage
Dim ImgLocal As Object
'
Chyba "File not found" pokud soubor neexistuje
If
Len(Dir$(FileName)) = 0 Then Err.Raise 53
'
Otev°enφ souboru a naΦtenφ obsahu
handle = FreeFile
Open FileName For Binary As #handle
Get #handle, , varTemp
Close #handle
'
p°ebudovßnφ objektu property bag
pb.Contents
= varTemp
'
vytvo°en doΦasnΘho ImageListu, kter² nenφ na ₧ßdnΘm formulß°i
Set
ImgLocal = pb.ReadProperty("IMG")
'
Proto₧e nelze vymazat koleci ListImage cφlovΘ komponenty
' ImageList, pokud je svßzßna s jinou komponentou,
' je jedinß cesta, jak zam∞nit obrßzky z doΦasnΘho
ImageListu
' do sφlovΘho ImageListu pomocφ ImageList_ReplaceIcon
API
For Each Li In ImgLocal.ListImages
ImageList_ReplaceIcon ImageList.hImageList,
Li.Index - 1, _
Li.Picture.handle
Next
End Sub
|