Load images from the web with rvHTMLViewImport...

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Load images from the web with rvHTMLViewImport...

Post by Marsianin »

Is there a demo on how to load images from Internet when using rvHTMlViewImport?

Also is there an easy way to paste HTML from clipboard using rvHTMLViewImport?
There is no paste method so I need to manually import from string from the clipboard location pointer. And images, again...
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

THTMLViewer has the event OnImageRequest where you can download the image.
THTMLViewer cannot paste from the Clipboard.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

I understand that you do not support THTMLViewer but I can't get OnImageRequest working in C++. Can you please help me out? I guess that my function is not correct.

Code: Select all

HTMLViewer1->OnImageRequest = HTMLViewerImageRequest;

void __fastcall TForm1::HTMLViewerImageRequest(TObject *Sender, const String SRC, TMemoryStream *Stream)
{
// do something
}
The error I receive is:

Code: Select all

[C++ Error] Unit1.cpp(341): E2034 Cannot convert 'void (_fastcall * (_closure )(TObject *,const AnsiString,TMemoryStream *))(TObject *,const AnsiString,TMemoryStream *)' to 'TGetImageEvent'
Thank you in advance for your help!
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The last parameter should be TMemoryStream* &Stream.

BTW, if you use TRVHtmlViewImporter, it's better using TRichView.OnImportPicture instead of HTMLViewer.OnImageRequest.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Thank you for your response. I'd like to understand the OnImageRequest function to use other Request functions.

My real problems are external CSS files. These files need to be downloaded to set the styles correctly.

For handling CSS files I need the OnhtStreamRequest function right?
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Thank you for your help! I created the htStreamRequest for downloading CSS files. It works excellent! :)
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Import external CSS files? HOW?
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Code: Select all

void __fastcall TForm1::HTMLViewerhtStreamRequest(TObject *Sender, const String SRC, TMemoryStream* &Stream)
{
  TMemoryStream *memStream = new TMemoryStream();
  try	{
		  IdHTTP1->Get(sDomain + SRC, memStream);
		  memStream->Position = 0;
		  Stream = new TMemoryStream();
		  Stream->LoadFromStream(memStream);
		}
  __finally
		{
		  memStream->Free();
		}   
}
//-----------------------------------------------------------------------------
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Thanks, but it seems this event never fires when using HTMLViewer for paste HTML from clipboard. It seems there is no header information in clipboard.
I'm using HTMLViewer to paste HTML from clipboard...
Post Reply