- This topic has 4 replies, 2 voices, and was last updated 12 years, 12 months ago by ralfiii.
-
AuthorPosts
-
November 23, 2011 at 2:09 pm #34911ralfiiiParticipant
I want to add some png-images at runtime to a TsAlphaImageList.
I tried the following code:
Code:strm:=TFileStream.Create(JvFilenameEdit1.Text, fmOpenRead or fmShareDenyNone);
with TsImgListItem(sAlphaImageList1.Items.Add) do
begin
ImageFormat := ifPNG;
PixelFormat := pf32bit;
ImgData.LoadFromStream(strm);
end;
strm.Free;For some reason it doesn't work, ImageList.Count doesn't change.
And one more: TsAlphaImageList.Clear doesn't work.
To verify:
Add a TsAlphaImageList to a form, all an images into the imagelist and the following code to a button:
Code:procedure TForm1.Button1Click(Sender: TObject);
begin
Caption:=IntTostr(sAlphaImageList1.Count);
sAlphaImageList1.Clear;
Caption:=Caption+' – '+IntTostr(sAlphaImageList1.Count);
Exit;result “1 – 1”
With TImageList: “1 – 0”.
HELP!
Thanks!
Ralf
November 24, 2011 at 3:54 pm #47246SupportKeymasterHello
Try such code
Code:sAlphaImageList1.Clear;
sAlphaImageList1.Items.Clear;
sAlphaImageList1.AcBeginUpdate;
strm:=TFileStream.Create(JvFilenameEdit1.Text, fmOpenRead or fmShareDenyNone);
with TsImgListItem(sAlphaImageList1.Items.Add) do
begin
ImageFormat := ifPNG;
PixelFormat := pf32bit;
ImgData.LoadFromStream(strm);
end;
strm.Free;
sAlphaImageList1.AcEndUpdate(True {ImgList updated here if True});Maybe this demo will be interested for you :
November 25, 2011 at 9:55 am #47249ralfiiiParticipantThis code doesn't do anything good.
For adding images I found a solution:
Code:with TsImgListItem(imgList.Items.Add) do
begin
ImageFormat := ifPNG;
PixelFormat := pf32bit;
ImgData.LoadFromStream(strmBinInDb);Png := TPNGGraphic.Create;
Png.LoadFromStream(ImgData);
Ico := MakeIcon32(Png);
ImageList_AddIcon(imgList.Handle, Ico);
DestroyIcon(Ico);
FreeAndNil(Png);
end;(…quite a lot of code…)
but Clear still doesn't work at all.
November 29, 2011 at 9:41 am #47272SupportKeymaster'ralfiii' wrote:but Clear still doesn't work at all.You uses this code?
Code:sAlphaImageList1.Clear;
sAlphaImageList1.Items.Clear;November 29, 2011 at 9:49 am #47273ralfiiiParticipantYes, I used
Code:Caption:=IntTostr(sAlphaImageList1.Count);
sAlphaImageList1.Clear;
sAlphaImageList1.Items.Clear;
Caption:=Caption+' – '+IntTostr(sAlphaImageList1.Count);And the result is “2 – 2”.
So before and after 2 images.
-
AuthorPosts
- You must be logged in to reply to this topic.