Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding pictures to ImageList
Message
From
06/05/2005 16:47:42
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01011780
Message ID:
01011794
Views:
25
This message has been marked as the solution to the initial question of the thread.
The add method is part of the ListImages collection:

thisform.ImageList1.ListImages.Add(index, key, picture)

(there are also clear, draw, extracticon and remove methods)

From MSDN help:

index Optional. An integer specifying the position where you want to insert the ListImage. If no index is specified, the ListImage is added to the end of the ListImages collection.

key Optional. A unique string that identifies the ListImage object. Use this value to retrieve a specific ListImage object. An error occurs if the key is not unique.

picture Required. Specifies the picture to be added to the collection.


Remarks

The ListImages collection is a 1-based collection.

You can load either bitmaps or icons into a ListImage object. To load a bitmap or icon, you can use the LoadPicture function, as follows:

Set imgX = ImageList1.ListImages.Add(,,LoadPicture("file name"))

You can also load a Picture object directly into the ListImage object. For example, this example loads a PictureBox control's picture into the ListImage object:

Set imgX = ImageList1.ListImages.Add(,,Picture1.Picture)

If no ListImage objects have been added to a ListImages collection, you can set the ImageHeight and ImageWidth properties before adding the first ListImage object. You can then add images of any size to the collection. However, when the ImageList control is bound to another Windows Common Control, all images you add to the collection will be displayed (in the bound Windows Common Control) at the size specified by the ImageHeight and ImageWidth properties. Once a ListImage object has been added to the collection, the ImageHeight and ImageWidth properties become read-only properties.

Note You can the use the ImageList control with any control by setting the Picture property of the second control to the Picture object of any image contained by the ImageList control. However, the size of the displayed image will not be affected by the ImageHeight and ImageWidth properties. In other words, the second control will display the image at its original size.

You should use the Key property to reference a ListImage object if you expect the value of the Index property to change. For example, if you allow users to add and delete their own images to the collection, the value of the Index property may change.

Note When using the ImageList control on a DHTML Page designer, images cannot be added at design time. If you try to use the Add method in an uncompiled .dll project, you will get the run-time error: -2147418113 (8000ffff), "Method 'Add' of object images failed". However, the code will work when the .dll project is compiled.
Previous
Reply
Map
View

Click here to load this message in the networking platform