Web Browser Control - controlling the background color...

G

Guest

I am using a web browser control to display some PPT slides saved as HTML. My
client has recently asked that the background of the browser be changed to
sonething other than white so that the slides "standout". I've tried setting
the browser's BackColor setting, but that had no effect at run time. Any
suggestions on how to control the default back color of content displayed in
a web browser control?
 
G

Guest

FYI, Also I've tried changing the back color in the PPT slides before
converting them to HTML - that works for the slide background but the space
around the slide is still white...
 
C

Charles Law

You could use

AxWebBrowser1.Document.bgColor = "..."

or

AxWebBrowser1.Document.body.style.backgroundColor = "..."

HTH

Charles
 
G

Guest

My web browser is part of my GUI... here's how its declared:
Friend WithEvents browser As AxSHDocVw.AxWebBrowser

So, when I tried
Me.browser.Document.bgColor = Color.Red
or
Me.browser.Document.body.style.backgroundColor = Color.Rad

I got a run time error. The only method that looks to be available under the
Document object is GetType.

Any other suggestions?
 
C

Charles Law

Option Strict On

....

Dim doc As mshtml.IHTMLDocument2

doc = DirectCast(browser, mshtml.IHTMLDocument2)

doc.bgColor = "Red"

or

doc.body.style.backgroundColor = ColorTranslator.ToHtml(CType(Color.Red,
Color))


Note that because these methods use the document attribute, they must be
called when the document has been loaded, either in the DocumentComplete
event or after it has fired.

HTH

Charles
 
G

Guest

Thanks for the reply, but I get compile error:
When I dimension "doc As mshtml.IHTMLDocument2" I get "...is not defined" -
Is there an Import statement that I am missing?

Thanks for your attention to this matter!
 
C

Charles Law

There is an import that you could use, but I do not recommend using it
because it will slow down the intellisense down tremendously.

The fact that you get a compile error suggests that the assembly is not in
your References. Right-click the References section in the solution explorer
and select Add Reference. Then add a reference to Microsoft.mshtml from the
list.

Charles
 
G

Guest

Very good, I was missing the Reference...

So, I implemented he code you suggested below in my methods that "...Handles
browser.DocumentComplete"...

Problem is that my results are still the same - when I load up the HTML, the
background outside the converted PPT slide is still white...

Thanks for your help thus far!
 
C

Charles Law

Are you certain that the border is not part of the converted slide?

You could also try posting this to
microsoft.public.inetsdk.programming.webbrowser_ctl, where Igor lives.

Charles
 
G

Guest

No I'm not sure - being an HTML novice I'm not sure how to tell either... but
it looks like is now realted to the HTML, so I'll dig in an see is there's a
background colr being controled by the conversion of the PPT to HTML...
thanks for your help.
I'll repost this thread as you suggested.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top