Adding a picture with specific size (like HTML)

General TRichView support forum. Please post your questions here
Post Reply
EugenioAndres
Posts: 7
Joined: Mon Sep 12, 2005 3:41 am

Adding a picture with specific size (like HTML)

Post by EugenioAndres »

Hi,

Is there a way to insert a picture into a TRichView giving it a specific size, independently of the pixels in the image file itself? - like in HTML, when a width and heigth are specified.

Thanks in advance.
Guest

Post by Guest »

Sounds like you should do the resizing prior inserting the image though you may want to check out the various attributes associated with pictures in TRichView/Edit.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Document generation:

Code: Select all

rv.Clear;
..
rv.AddPictureEx(...);
rv.SetItemExtraIntProperty(rv.ItemCount-1, rvepImageHeight, 100);
rv.SetItemExtraIntProperty(rv.ItemCount-1, rvepImageWidth, 100);
...
rv.Format;
Inserting picture:

Code: Select all

if rve.InsertPicture(...) then begin
  rve.SetCurrentItemExtraIntProperty(rvepImageHeight, 100, True);
  rve.SetCurrentItemExtraIntProperty(rvepImageWidth, 100, True);
end;
This example is simple, but not very good, because user can update all these 3 operations (inserting, changing height, changing width) in 3 steps, calling Undo 3 times.
The code below solves this problem:

Code: Select all

rve.TopLevelEditor.BeginUndoGroup(rvutInsert);
rve.TopLevelEditor.SetUndoGroupMode(True);
if rve.InsertPicture(...) then begin
  rve.SetCurrentItemExtraIntProperty(rvepImageHeight, 100, True);
  rve.SetCurrentItemExtraIntProperty(rvepImageWidth, 100, True);
end;
rve.TopLevelEditor.SetUndoGroupMode(False);

Another example - document generation:
Post Reply