Re: axWebBrowser not displaying images

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks Mark...that helped. It was the way we were indicating the path. The
bitmap files still do not render but that's OK.
"Mark Dykun" <mdykun1243@xxxxxxxxxx> wrote in message
news:OyUc%23LPEIHA.4332@xxxxxxxxxxxxxxxxxxxxxxx
Tom,

This is clearly not the case. Because you are working with the local html
it needs to know where the image resided based on a correctly formatted
URL. To test this create a new C# winforms app, drop the webbrowser
control and a button on the form. Put a bitmap image in the c directory, I
created on with paint .net and called it file1.bmp. In the button click
event add the following code (make sure to change to the filename of your
image), run and press the button. The image will be displayed successfully
in the browser control.

webBrowser1.DocumentText = "<HTML><HEAD></HEAD><BODY><IMG
SRC='file://c:/file1.bmp' /></BODY></HTML>";

if your images are stored relative to the executing assembly you can
create the path based on that as append it onto your filenames ensuring
that it can file the file correctly.

I hope that this helps,

Mark

"Tom" <tom.gaughan@xxxxxxxxxxxxxxxxx> wrote in message
news:u0Y7imMEIHA.3980@xxxxxxxxxxxxxxxxxxxxxxx
The axWebBrowser will not render either the bmp or the jpg files. IE 7
will render the jpg file but not the bmp files. I've even tried
converting the bitmaps to GIF files and it's the same - IE7 OK,
axWebBrowser - Not OK.

Here's more...the HTML being sent to the axWebBrowser is a simple table
(below). Our first take on this was to generate an HTML file saved to
disk and launch IE. This will now work for us as we've learned that if
we change our file type to jpg or gif IE is cool with that. When we
tried to embed this report into the app we found that none of the file
types display. When we run the app and right click on the browser
control and do a view source, what displays in notepad is
<HTML></HTML>...I don't get that...

Here's the code that loads the browser control (axWeb06):

try

{

StringBuilder sbHtml = new StringBuilder();
axWeb06.Navigate("about:blank", ref _empty, ref _empty, ref _empty, ref
_empty);

_doc = axWeb06.Document as IHTMLDocument2;

//wait for document to load

while (_doc.body == null) Application.DoEvents();

strHitChart = "<table border=1><tr><td colspan=2 align=center><B>HIT
CHART " + lbHitTeam.Text + " " + lbHitYear.Text + " " + strDowns +
"Downs</td></tr><tr>";

sbHtml.Append (strHitChart);

// database queries follow to get the rest of the data and do subsequent
sbHtml.Append...

//write the HTML to the document's body

_doc.body.innerHTML = sbHtml.ToString();

}

catch(Exception ex)

{

MessageBox.Show("Error generating HIT Chart - " + ex.Message);

}

This is the html result:

<table border=1><tr><td colspan=2 align=center><B>HIT CHART OHIO 2005
1st&2nd Downs</td></tr><tr><td><table><tr><td><b><u>S UNO SL</u>: <font
color=Blue>TOL </font><font color=DeepPink>BSU </font><font
color=LimeGreen>BUFF </font></TD></TR><TR><TD width=400><b>BBPS:<font
color=DeepPink>1 </font><font color=LimeGreen>3 </font>BNCE NKO:<font
color=DeepPink>7 </font>BUB SCRN:<font color=Blue>1
</font></TD></TR><tr><td align=center><b>9 - 12</b></td></tr>
<tr><td><img src='Formation3.gif'></img> </td></tr><TR><TD
width=400><b>ZN:<font color=Blue>2 </font><font color=DeepPink>1
</font>ZN WK:<font color=Blue>2 </font><font color=DeepPink>4
</font></TD></TR></table></td><td><table><tr><td><b><u>GO UNO</u>: <font
color=Blue>TOL </font><font color=DeepPink>BSU </font><font
color=LimeGreen>BUFF </font></TD></TR><TR><TD width=400><b>Z SWP NKD
WK:<font color=Blue>7 </font><font color=DeepPink>1 </font>Z SWP ROLL TRW
BK:<font color=LimeGreen>1 </font></TD></TR><tr><td align=center><b>3 -
9</b></td></tr> <tr><td><img src='Formation4.gif'></img>
</td></tr><TR><TD width=400><b>FK HND SWP QB CTR T:<font
color=LimeGreen>1 </font>Z SWP:<font color=LimeGreen>2
</font></TD></TR></table></td></tr><tr><td><table><tr><td><b><u>GO UNO
SL</u>: <font color=LimeGreen>BUFF </font></TD></TR><TR><TD
width=400><b>BNCE BT:<font color=LimeGreen>1 </font>STRCH BT:<font
color=LimeGreen>1 </font></TD></TR><tr><td align=center><b>0 -
2</b></td></tr> <tr><td><img src='Formation6.gif'></img>
</td></tr><TR><TD
width=400><b></TD></TR></table></td><td><table><tr><td><b><u>GU UNO</u>:
<font color=DeepPink>BSU </font></TD></TR><TR><TD
width=400><b></TD></TR><tr><td align=center><b>6 - 0</b></td></tr>
<tr><td><img src='Formation7.gif'></img> </td></tr><TR><TD
width=400><b>ZN:<font color=DeepPink>5 </font>ZN WK:<font
color=DeepPink>1 </font></TD></TR></table></td></tr><tr></tr></table>


"Registered User" <n4jvp@xxxxxxxxxxxxx> wrote in message
news:c33ch3hm3ofst73gcjqnvekipjedbloain@xxxxxxxxxx
On Tue, 16 Oct 2007 13:39:08 -0400, "Tom"
<tom.gaughan@xxxxxxxxxxxxxxxxx> wrote:

Any idea why IE won't render bitmaps?

Where using a basic img tag:
<img src='formationimages\\formation" + intFormationID + ".jpg'>


Would it work if the extension in the example were changed to ".bmp"?

regards
A.G.






.



Relevant Pages

  • Re: HTML Thumbnail
    ... Render the HTML to a browser control ... Place screen shot in a picturebox and re-scale. ... I think you can't get away from rendering the HTML to a browser. ...
    (microsoft.public.vb.general.discussion)
  • Re: controllable java HTML render?
    ... Presumably you render the HTML to a bitmap, discard the HTML and further process the bitmap. ...
    (comp.lang.java.gui)
  • Viewin HTML in Winform application
    ... I am looking for a way to view HTML in Winform application. ... Does anyone know if there is something like a browser control that I could use to render the HTML? ...
    (microsoft.public.dotnet.framework.windowsforms)
  • CDHtmlDialog
    ... created bitmap. ... Save bitmap to a file and then load it and show it from html. ... I also tried to use OnPaint method of CDHtmlDialog but it seems that Html ...
    (microsoft.public.vc.mfc)
  • Re: Forms.Webbrowser not looking at CSS file
    ... When I take the html that I am giving the WebBrowser and stick it in a file and open the file the styles are working. ... If you load a file or URL in the web browser control then the relative URL can be resolved with the file/URL as the base URI but if you load a string then there is no base URI the browser could use. ...
    (microsoft.public.dotnet.xml)