Beispiel #1
0
        public static Rectangle GetElementRect(mshtml.IHTMLElement body, mshtml.IHTMLElement elem)
        {
            int top;
            int num3;
            int num4;
            int left = top = num3 = num4 = 0;

            mshtml.IHTMLElement2 element = elem as mshtml.IHTMLElement2;
            IHTMLRect            o       = element.getBoundingClientRect();

            elem = element as mshtml.IHTMLElement;
            left = o.left;
            top  = o.top;
            num3 = o.right - o.left;
            num4 = o.bottom - o.top;
            if (body.document != elem.document)
            {
                List <mshtml.IHTMLDOMNode> frames = new List <mshtml.IHTMLDOMNode>();
                GetEleParentFrames(body as mshtml.IHTMLDOMNode, elem as mshtml.IHTMLDOMNode, frames);
                foreach (mshtml.IHTMLDOMNode node in frames)
                {
                    IHTMLRect rect2 = (node as mshtml.IHTMLElement2).getBoundingClientRect();
                    left += rect2.left;
                    top  += rect2.top;
                }
            }
            Rectangle rectangle = new Rectangle {
                X      = left,
                Y      = top,
                Width  = num3,
                Height = num4
            };

            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            return(rectangle);
        }
Beispiel #2
0
 public static IHTMLRect GetLocation(HtmlElement he)
 {
     mshtml.IHTMLElement2 domElement = (mshtml.IHTMLElement2)he.DomElement;
     return(domElement.getBoundingClientRect());
 }