Page 1 of 1

Load images from the web with rvHTMLViewImport...

Posted: Fri Aug 29, 2008 5:35 am
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...

Posted: Fri Aug 29, 2008 5:20 pm
by Sergey Tkachenko
THTMLViewer has the event OnImageRequest where you can download the image.
THTMLViewer cannot paste from the Clipboard.

Posted: Tue May 04, 2010 1:30 pm
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!

Posted: Tue May 04, 2010 3:49 pm
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.

Posted: Wed May 05, 2010 7:13 am
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?

Posted: Wed May 05, 2010 7:19 am
by Pieter E.
Thank you for your help! I created the htStreamRequest for downloading CSS files. It works excellent! :)

Posted: Fri May 07, 2010 7:26 am
by Marsianin
Import external CSS files? HOW?

Posted: Sat May 08, 2010 12:10 pm
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();
		}   
}
//-----------------------------------------------------------------------------

Posted: Sat May 08, 2010 8:34 pm
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...