Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

LoadImageList - Reload the images in an ImageList control

Total Hit ( 2551)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
Private Declare Function ImageList_ReplaceIcon Lib "COMCTL32" (ByVal hImageList _
  As Long, ByVal i As Long, ByVal hIcon As Long) As Long

' Load a set of images from a disk file to a ImageList control
' The file must have been saved using the SaveImageList control, and the
' target ImageList control must contain enough images in its
' ListImage collection.

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  ' can use early binding here!
  
  ' Error "File not found" if the file doesn't exisit
  If Len(Dir$(FileName)) = 0 Then Err.Raise 53
  
  ' Open the file and read its contents
  handle = FreeFile
  Open FileName For Binary As #handle
  Get #handle, , varTemp
  Close #handle
  
  ' rebuild the property bag object
  pb.Contents = varTemp
  ' create a temporary ImageList control that isn't sited on any form
  Set ImgLocal = pb.ReadProperty("IMG")
  
  ' because we can't clear the ListImage collection of the target
  ' ImageList control if the control is bound to any other control,
  ' the only way to move the images from the temporary ImageList to
  ' the target ImageList is using the ImageList_ReplaceIcon API
  For Each Li In ImgLocal.ListImages
    ImageList_ReplaceIcon ImageList.hImageList, Li.Index - 1, _
      Li.Picture.handle
  Next
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.