Hi Efran, and thank you for that tip. I can, however, not get it to work 
properly. What I am using as a test is an MHT page as saved from Internet 
Explorer 7 based on a very very basic html page with only one image and some 
lines of text on it. The output is not rendered correctly in the .net 
WebBrowser control, and the image is not shown.

Is the MHT that I feed the stream supposed to be different from the contents of 
an MHT file as saved by IE?

Eyvind.

-----Opprinnelig melding-----
Fra: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] På vegne av 
Efran Cobisi
Sendt: 10. mai 2007 14:06
Til: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Emne: Re: [ADVANCED-DOTNET] Displaying an image in a WebBrowser without saving 
it to disk first (WinForms)

Eyvind,

This is easily solvable; using the DocumentStream property [1] of the
WebBrowser control would do the trick.
An example to start from:

MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
writer.Write(yourDynamicallyGeneratedMhtml);
writer.Flush();
stream.Position = 0;

yourWebBrowserControl.DocumentStream = stream;

[1]
http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.documentstream.aspx

HTH

--
Efran Cobisi
http://www.cobisi.com

Eyvind Axelsen wrote:
> Yes, I have looked at mht files, and that seems like a good option. However, 
> I am unable to load an mht file from an embedded resource into the WebBrowser 
> control. Just setting the DocumentText property to the string contents of the 
> mht does not work. When the mht file resides on disk (which I do not want), 
> displaying it via the Navigate() method works perfectly. Any pointers would 
> be greatly appreciated.
>
> Eyvind.
>


===================================
This list is hosted by DevelopMentor  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to