Hi, I'd like know how search for a image (by name) and replace with another image. In runtime!
Nowadays I am finding the image using GetItem(x), but I am having difficulties with replace the image.
Search image and change it
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I am using the code:
It does not show error, but does not change the image also.
Can you help me fix it? And I'd like to maintain the width and height of the previous image.
Code: Select all
SRichViewEdit1.StartEditing(srvrveHeader);
for x := 0 to SRichViewEdit1.ActiveEditor.ItemCount-1 do
begin
if SRichViewEdit1.ActiveEditor.GetItemStyle(x) = rvsPicture then
begin
SRichViewEdit1.ActiveEditor.GetPictureInfo(x,AName,Agr,AVAlign,ATag);
if ListBoxCamposImagem.Items.IndexOf(AName) > -1 then
begin
bmp := TBitmap.Create;
bmp.LoadFromFile('img.bmp');
SRichViewEdit1.ActiveEditor.SetPictureInfo(x,AName,bmp,AVAlign,ATag);
SRichViewEdit1.Format;
bmp.free;
end;
end;
end;
Can you help me fix it? And I'd like to maintain the width and height of the previous image.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Does not free bmp, after calling SetPictureInfo it's owned by the editor.
Call Format one time at the end, instead of after each replacement.
Note: this code processes only the main document, it does not change pictures in table cells, footnotes, endnotes and text boxes.
If you need, I can explain how to do it.
Call Format one time at the end, instead of after each replacement.
Note: this code processes only the main document, it does not change pictures in table cells, footnotes, endnotes and text boxes.
If you need, I can explain how to do it.