Page 1 of 1
TRVHTMLViewImporter.ImportPicture can not load from URL
Posted: Sat Jul 06, 2013 7:38 am
by gbg
how TRVHTMLViewImporter.ImportPicture canload from URL?
Posted: Sat Jul 06, 2013 7:43 am
by Sergey Tkachenko
It cannot. But you can process TRichView.OnImportPicture and download picture in this event.
If you use RichViewActions, they can do it for you, if you enable support of either Indy or CleverComponents.
Posted: Sat Jul 06, 2013 7:56 am
by gbg
thanks
i use CleverComponents
but don`t use RichViewActions
how download picture in TRichView.OnImportPicture event?
Posted: Sat Jul 06, 2013 8:24 am
by gbg
gbg wrote:thanks
i use CleverComponents
but don`t use RichViewActions
how download picture in TRichView.OnImportPicture event?
i run demo in
http://www.trichview.com/resources/clev ... client.zip
Posted: Sat Jul 06, 2013 11:02 am
by Sergey Tkachenko
Even if you do not use RichViewActions (by the way, the Clever Email Client demo uses RichViewActions), you can look in RichViewActions.pas how it is implemented.
Specifically, TRVAControlPanel.DoImportPicture.
The brief scheme is the following. If Locatiom starts from 'http://', then ...
1. Create TMemoryStream
2. Using clHTTP.Get, download the image in this stream.
3. Unfortunately, it is problematic to determine a graphic class by the file extension, so RichViewActions do the following: saving this stream to a temporary file name (with file extension taken from URL) and loading from a file using RVGraphicHandler.LoadFromFile. You can use the same idea, or create your own procedure for loading an image directly from a stream, determining the required graphic class by extension.
Otherwise load an image from a local file.
If downloading/loading fails, you can provide an "error" image.
Very often, HTML contains multiple references to the same image (this forum is an example of such pages). To speed up downloading, you can create a list of downloaded images (In RichViewActions, it is called FDownloadedPictures), and if the image already in the list, return its copy instead of redownloading.
Posted: Sat Jul 06, 2013 11:28 am
by gbg
i download fresh copy of demo but i didn`t see RichViewActions!
exe file work corectly but when i compile , exe file can not show image!
and i down`t find method DoImportPicture in TRVAControlPanel.
Posted: Sat Jul 06, 2013 12:34 pm
by Sergey Tkachenko
1) You need to recompile the RichViewActions package after enabling support of CleverComponents:
http://www.trichview.com/help-actions/c ... onents.htm
2) In TfrmComposeHTMLEMail form (clRVSendDialog.pas), TclHTTP component must be placed on the form and assigned to RVAControlPanel1.
As I can see, this demo needs an update related to TRVAControlPanel: the demo assumes that a control panel properties change global variables, but it is not so since TRichView 14.
I'll update this demo later in this week.
Posted: Sat Jul 06, 2013 3:28 pm
by gbg
Posted: Sat Jul 06, 2013 3:13 pm Post subject: whats next step!
thanks
i add cl packe then place clHttp1 on form
and add this line in TfrmComposeHTMLEMail.FormCreate
RVAControlPanel1.ClHTTP:=clHttp1;
but can not download picture
*sorry i create new post
Posted: Sun Jul 07, 2013 6:00 am
by Sergey Tkachenko
Do you have another form with TRVAControlPanel? This demo is a bit outdated, it does not work correctly, if you have another TRVAControlPanel when the email editing dialog is shown.
I'll update it today or tomorrow.
Posted: Sun Jul 07, 2013 8:14 am
by gbg
Sergey Tkachenko wrote:Do you have another form with TRVAControlPanel? This demo is a bit outdated, it does not work correctly, if you have another TRVAControlPanel when the email editing dialog is shown.
I'll update it today or tomorrow.
no i have one form.
But I've changed some of the source code, I have added a search in the inbox,show the attachment icon in listview if email have attach file,...
Posted: Sun Jul 07, 2013 3:23 pm
by Sergey Tkachenko
I updated
http://www.trichview.com/resources/clev ... rdemos.zip
1) RVAControlPanel1 is placed on the email composing form. It is directly assigned to all actions on the form. The previous code did not work properly if another instance of TRVAControlPanel was already created.
2) clHTTP1 is placed on the email composing form, and assigned to RVAControlPanel1.clHTTP. So now this editor can download images when pasting RTF with links.
I tested - image downloading code works properly.
If it does not work as you expect, please give me a step-by-step instructions how to reproduce.
Posted: Sun Jul 07, 2013 4:30 pm
by gbg
thanks
work correctly