Does RichView had any interface to insert picture?

General TRichView support forum. Please post your questions here
Post Reply
Guest

Does RichView had any interface to insert picture?

Post by Guest »

I want a richedit inherit richview ,or richview has the richedit's property,how can i do that? And the most important is that when i complete,i want get all the picture's source path, how can i do that?
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Inserting picture? It's simple:

Code: Select all

var bmp: TBitmap;

bmp := TBitmap.Create;
bmp.LoadFromFile('c:\pic.bmp');
RichViewEdit1.InsertPicture('', bmp, rvvaBaseline);
About storing picture file name, there are two ways to do it.
The simplest way is to store it in the "item name" - text value associated in TRichView with any picture:

Code: Select all

bmp := TBitmap.Create;
bmp.LoadFromFile('c:\pic.bmp');
RichViewEdit1.InsertPicture('c:\pic.bmp', bmp, rvvaBaseline);

// reading name from the picture at the position of caret
FileName := RichViewEdit1.GetCurrentItemText;
But the recommended way for storing image file name is a special "file name" item property. It was specially designed for storing image file names.

Code: Select all

bmp := TBitmap.Create;
bmp.LoadFromFile('c:\pic.bmp');

RichViewEdit1.TopLevelEditor.BeginUndoGroup(rvutInsert);
RichViewEdit1.TopLevelEditor.SetUndoGroupMode(True);
try
  if RichViewEdit1.InsertPicture('', bmp, rvvaBaseline) then
    RichViewEdit1.SetCurrentItemExtraStrProperty(rvespImageFileName, 'c:\pic.bmp', True);
finally
  RichViewEdit1.TopLevelEditor.SetUndoGroupMode(False);
end;

// reading file name from the picture at the position of caret
RichViewEdit1.GetCurrentItemText(rvespImageFileName, FileName);
Post Reply