Getting IHTMLStyle3 from Dom HtmlElement in IE

I have a System.Windows.Form.WebBrowser control in a form. I am moving this browser object to a URL.

Once the page has finished loading, I would like to analyze the various aspects of the loaded page.

In particular, I am interested to see the attribute 'writingMode', which is located on the IHTMLStyle3 interface.

Sort of:

public void MyMethod(HtmlElement element)
    {
        IHTMLElement2 element2 = element.DomElement as IHTMLElement2;
        IHTMLStyle3 style3 = element2.currentStyle as IHTMLStyle3;

        string writingMode = style3.writingMode;
    ...

The problem is that the value of style3 is null. I assume this means that IHTMLElement2.currentStyle does not support IHTMLStyle3.

I tried and tried casting IHTMLELement.style. But while it does happily, like IHTMLStyle3, it does not seem to contain the style that was applied to the Html element.

+3
1

, , IHTMLElement2.currentStyle, style . IHTMLElement2.currentStyle:

, IHTMLStyle IHTMLCurrentStyle . , - , IHTMLCurrentStyle:: color red, IHTMLStyle:: get_color . , inline, IHTMLCurrentStyle:: IHTMLStyle:: get_color .

currentStyle IHTMLCurrentStyle, IHTMLCurrentStyle2 writingMode .

+1

Source: https://habr.com/ru/post/1703816/


All Articles