how to copy text from report preview?

I have a simple report shown on the screen in preview, using Report1.show(true) in Delphi.


Is there any simple way I can mark some of the text with the mouse and copy it onto the clipboard (ie like you can when using notepad or a word processor)


At the moment the cursor is a hand shape and I can move through the report using the mouse but I don't seem to be able to select any of the text.

Comments

  • I'll answer this myself using Delphi 2009 and FR4.


    include in Delphi the unit 'uses ClipBrd;'


    Then make the report interactive by using the Report's OnClickObject event .

    In this event put the code


    procedure TFrmMain.frxReport1ClickObject(Sender: TfrxView;   Button: TMouseButton;    Shift: TShiftState;   var Modified: Boolean);

    begin

      Clipboard.AsText := TfrxMemoView(Sender).Text ;

      ShowMessage('copied');

    end;


    This works to copy the text of a memo with a left click but could probably be improved by highlighting the memo somehow to indicate that it has been copied or making it work using the left button (instead of showing a context menu or better still, by adding 'copy' to the context menu)


    Note:

    The OnClickObject procedure prototype in Fastreport's documentation is different from that in the actual installation (at least in FR4). The documentation shows an additional 'page' parameter and the TfrxView parameter is called 'View' and not 'Sender' as shown below


    procedure TForm1.frxReport1ClickObject(Page: TfrxPage; View: TfrxView;  Button: TMouseButton;  Shift: TShiftState;    var Modified: Boolean);


    And the documentation says to use TfrxMemoView(View). In my version of FR4 I had to use TfrxMemoView(Sender)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.