Page 1 of 1
Text and Image Drag&Drop...
Posted: Wed Nov 15, 2017 11:23 am
by CrimsonKing
Hi~
First, Excuse me for my poor English.
I tried to drag Texts+Images from Internet Explorer(IE) and drop its to TRichviewEdit(RVE), but dropped only Texts to RVE.
Resultly, Texts or Images dropped to RVE only one at time.
How can I drag&drop Texts+Images to RVE at once?
Is it possible?
Re: Text and Image Drag&Drop...
Posted: Wed Nov 15, 2017 12:23 pm
by Sergey Tkachenko
If you drop a single image, IE provides it as a reference to a file (in its cache), so TRichView can easily read it.
If you drop a page fragment containing text and pictures, IE provides it as plain text, RTF, and HTML. By default, TRichViewEdit reads it as RTF.
This RTF contains references to picture URLs. TRichView cannot download it itself, you need to help it.
If you use RichViewActions, it's more simple. If you assign RVAControlPanel.DownloadInterface, RichViewActons download external images when you load, insert and paste files. However, to download them on drag&drop, you need to add code in OnBeforeOleDrop and OnAfterOleDrop, see
http://www.trichview.com/help/idh_trich ... edrop.html
Re: Text and Image Drag&Drop...
Posted: Tue Dec 19, 2017 1:41 am
by CrimsonKing
Very Late, I see your kindly answer...
I did the test as you answered, but it doesn't work the way I want it to.
Text is dropping but images aren't downloaded.
I've looked at this document...
http://www.trichview.com/forums/viewtop ... ace#p31614
I tested using RVControlPanel, DownloadInterface and IndyHTTP. but it doesn't work like it should.
I set properties...
- rvControlPanel.DefaultControl := rve;
- rvControlPanel.DownloadInterface := rvDownloadInterface;
- rvDownloadInterface.IdHttp := IndyHttp;
It's my source code below...
Code: Select all
procedure TMyForm.rveBeforeOleDrop(Sender: TObject);
begin
rvControlPanel.InitImportPictures(nil, nil);
(Sender as TCustomRichViewEdit).OnImportPicture := rvControlPanel.DoImportPicture;
end;
procedure TMyForm.rveAfterOleDrop(Sender: TObject);
var
W, X: Integer;
begin
(Sender as TCustomRichViewEdit).OnImportPicture := nil;
rvControlPanel.DoneImportPictures;
end;
And I try drop&drop to rve from Texts&Pictures in IE, but it doesn't work...
I don't know why rvControlPanel.DoImportPicture doesn't do anything.
Help me plz...
Re: Text and Image Drag&Drop...
Posted: Tue Dec 19, 2017 2:55 pm
by Sergey Tkachenko
From which page do you drag?
Re: Text and Image Drag&Drop...
Posted: Wed Dec 20, 2017 12:28 am
by CrimsonKing
I scrap text & image from IE and drag & drop to rve.
For example...
- sample1.JPG (46.87 KiB) Viewed 21843 times
https://www.nytimes.com/2017/11/11/wor ... e=article
The below picture is the result of rve.
- rev.jpg (88.71 KiB) Viewed 21843 times
Re: Text and Image Drag&Drop...
Posted: Thu Dec 28, 2017 5:35 am
by CrimsonKing
May I have an answer to this?
Re: Text and Image Drag&Drop...
Posted: Thu Dec 28, 2017 7:21 pm
by Sergey Tkachenko
I tested, it works as expected. I attached a sample project.
Important note 1: it works only when dragging from Internet Explorer, because it provides RTF format when copying or dragging.
It does not work when dragging from other browsers (including Edge, FireFox and Chrome), because they do not provide RTF, so their content is inserted in TRichViewEdit as a plain text.
Important note 2: Internet Explorer does not provide RTF for "too complex" content, that includes many nested tables. So, if it does not work, try dragging a smaller fragment.
The problems above could be solved by using HTML format instead of RTF: all major browsers provide content as HTML.
For pasting, it's simple to do, especially using RichViewActions: assign TrvHtmlImporter, or (better) TrvHtmlViewImporter to RVAControlPanel.HTMLComponent.
For drag&drop, it's more difficult, it requires writing quite low-level code in OnOle*** events. Probably, in future versions, I'll simplify it.