TRVHTMLViewImporter.ImportPicture can not load from URL

General TRichView support forum. Please post your questions here
Post Reply
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

TRVHTMLViewImporter.ImportPicture can not load from URL

Post by gbg »

how TRVHTMLViewImporter.ImportPicture canload from URL?
:roll:
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post by gbg »

thanks

i use CleverComponents
but don`t use RichViewActions

how download picture in TRichView.OnImportPicture event?
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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.

:oops:
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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,...
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post by gbg »

thanks
work correctly
Post Reply