TRVHTMLViewImporter.ImportPicture can not load from URL
TRVHTMLViewImporter.ImportPicture can not load from URL
how TRVHTMLViewImporter.ImportPicture canload from URL?
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
i run demo in http://www.trichview.com/resources/clev ... client.zipgbg wrote:thanks
i use CleverComponents
but don`t use RichViewActions
how download picture in TRichView.OnImportPicture event?
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
no i have one form.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.
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,...
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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.