Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Mark Leighton Fisher (4252)

Mark Leighton Fisher
  (email not shown publicly)
http://mark-fisher.home.mindspring.com/

I am a Systems Engineer at Regenstrief Institute [regenstrief.org]. I also own Fisher's Creek Consulting [comcast.net].
Friday February 03, 2006
12:31 PM

The IE Web Browser Control and Applying Styles

[ #28571 ]

Applying styles or rather trying to apply styles to HTML destined to live inside the IE Web Browser Control can be problematic. If you generate the HTML dynamically into a string to be displayed by the control, then you lose the capability to apply global styles (styles using CLASS or element name definitions in the HEAD section). This is because the Microsoft HTML Object Library (mshtml.dll) used by the IE Web Browser Control only supports assigning BODY element contents as a string. Now, the HTML string *can* have a HEAD section -- it is just ignored by the control, which (IMHO) confuses the matter.

The HTML-only solution is to write the HTML to a temporary file, then display that file. Writing the string to a file to be displayed also helps you use stylesheets, as they are also specified in the HEAD section.

Here is an example of setting global styles in code when you load the HTML as a string:

objCSS = wb.Document.createStyleSheet
objCSS.addRule "H1", "{ font-size: 120%; line-height: 10%; }"
objCSS.addRule "BR", "{ font-size: 80%; line-height: 20%; }"
objCSS.addRule "TR", "{ font-size: 80%; line-height: 10%; }"
objCSS.addRule "TH", "{ font-size: 80%; line-height: 10%; }"
objCSS.addRule "TD", "{ font-size: 80%; line-height: 10%; }"
objCSS.addRule "DIV", "{ font-size: 80%; line-height: 10%; }"

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.