你的意思是有了一个TImageList和一些Image,想要把Image放到TImageList里面去吧?在TImageList的父类TCustomImageList里面有个Add方法可以做到,看Delphi里面的帮助 Adds an Image and its Mask to the image list object. function Add(Image, Mask: TBitmap): Integer;DescriptionUse the Add method to add images with their masks to an image list. It returns the index of the added image, or -1 if it fails. When the Masked property of the image list is False, the second bitmap handle is ignored; it can be set to nil.这样你就可以把一个Image加入到ImageList里面了阿
You can use code to realize your purpose. The TImageList maybe have this kind of method.
找不到imageindex属性?ImageList.Count
function Add(Image, Mask: TBitmap): Integer;Add函数的返回值就是Index.
非常简单! var bmp:Tbitmap; begin Imagelist.GetBitmap(1,bmp); Image.Assign(bmp); end;1为图在ImageList中的序号,ico就变为Imagelist.GetIco
begin Imagelist1.GetIcon(strtoint(edit1.Text),icon); Image1.Picture.Assign(icon) end; 功能已经能实现,但form的icon会随着改变,我要求它不能变化,只有 image才能变化,该怎么改代码呢
变量不能用icon,因为这里的icon就是Form.icon,即窗体图标! 换成 var myico:TIcon begin Imagelist1.GetIcon(strtoint(edit1.Text),myico); Image1.Picture.Assign(myico) end; 就好了!没问题了吧!
Adds an Image and its Mask to the image list object. function Add(Image, Mask: TBitmap): Integer;DescriptionUse the Add method to add images with their masks to an image list. It returns the index of the added image, or -1 if it fails. When the Masked property of the image list is False, the second bitmap handle is ignored; it can be set to nil.这样你就可以把一个Image加入到ImageList里面了阿
var bmp:Tbitmap;
begin
Imagelist.GetBitmap(1,bmp);
Image.Assign(bmp);
end;1为图在ImageList中的序号,ico就变为Imagelist.GetIco
不过好象用起来有问题
Imagelist1.GetIcon(strtoint(edit1.Text),icon);
Image1.Picture.Assign(icon)
end;
功能已经能实现,但form的icon会随着改变,我要求它不能变化,只有 image才能变化,该怎么改代码呢
换成
var myico:TIcon
begin
Imagelist1.GetIcon(strtoint(edit1.Text),myico);
Image1.Picture.Assign(myico)
end;
就好了!没问题了吧!