Copy Images as a Text to Clipboard

General TRichView support forum. Please post your questions here
Post Reply
Jacek Puczynski
Posts: 27
Joined: Tue Jun 20, 2006 7:34 pm
Location: Europe

Copy Images as a Text to Clipboard

Post by Jacek Puczynski »

Hello I have a problem with my TRichView:

In the document there is a lot of text and small images.
Now, when user selects the text with the images for copy to clipboard images are ignored ( I use CopyText() method).
Now I would like to make the copying better and copy text with images like that
text text text <image Name> text text text
I use AddPictureEx with Name value that I want to be visible after copy.

How can I do it?

Thanks. Jacek.
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Unfortunately, the current TRichView version does not allow this.
You can use a low level event OnSaveComponentToFile to modify how images are saved in text, but it will not affect methods for copying or saving selection, only methods for saving the complete text:

Code: Select all

uses CRVData, RVUni;
procedure TForm1.RichViewEdit1SaveItemToFile(Sender: TCustomRichView;
  const Path: String; RVData: TCustomRVData; ItemNo: Integer;
  SaveFormat: TRVSaveFormat; Unicode: Boolean;
  var OutStr: TRVRawByteString; var DoDefault: Boolean);
var s: String;
begin
  if (SaveFormat<>rvsfText) then
    exit;
  if (RVData.GetItemStyle(ItemNo)<>rvsPicture) and
     (RVData.GetItemStyle(ItemNo)<>rvsHotPicture) then
    exit;
  RVData.GetItemExtraStrProperty(ItemNo, rvespAlt, s);
  if s='' then
    s := 'image';
  s := '<'+s+'>';
  DoDefault := False;
  // for Delphi 4-2007
  if Unicode then
    OutStr := RVU_AnsiToUnicode(RVData.GetRVStyle.DefCodePage, s)
  else
    OutStr := s;
  {
  // for Delphi 2009
  if not Unicode then
    OutStr := RVU_UnicodeToAnsi(RVData.GetRVStyle.DefCodePage, RVU_GetRawUnicode(s))
  else
    OutStr := RVU_GetRawUnicode(s);
  }
end;
Jacek Puczynski
Posts: 27
Joined: Tue Jun 20, 2006 7:34 pm
Location: Europe

Post by Jacek Puczynski »

Thank you for your answer.

Hope it will be consider as a new feature for next versions.

Regards, Jacek.
Post Reply