当前位置: 首页>>代码示例>>C#>>正文


C# IHTMLDocument2.elementFromPoint方法代码示例

本文整理汇总了C#中IHTMLDocument2.elementFromPoint方法的典型用法代码示例。如果您正苦于以下问题:C# IHTMLDocument2.elementFromPoint方法的具体用法?C# IHTMLDocument2.elementFromPoint怎么用?C# IHTMLDocument2.elementFromPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHTMLDocument2的用法示例。


在下文中一共展示了IHTMLDocument2.elementFromPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindElement

 public static IHTMLElement FindElement(IntPtr fromHandle, IHTMLDocument2 doc, int x, int y)
 {
     IHTMLElement elem = null;
     Rect lpRect = new Rect();
     WindowUtil.GetWindowRect(fromHandle, out lpRect);
     elem = doc.elementFromPoint(x - lpRect.Left, y - lpRect.Top);
     while (((elem != null) && (elem.tagName != null)) && (elem.tagName.ToLower().Equals("iframe") || elem.tagName.ToLower().Equals("frame")))
     {
         Rectangle elementRect = GetElementRect(doc.body, elem);
         IWebBrowser2 o = elem as IWebBrowser2;
         IHTMLDocument2 document = o.Document as IHTMLDocument2;
         IHTMLElement element2 = document.elementFromPoint((x - lpRect.Left) - elementRect.X, (y - lpRect.Top) - elementRect.Y);
         if (element2 != null)
         {
             elem = element2;
         }
         Marshal.ReleaseComObject(document);
         Marshal.ReleaseComObject(o);
     }
     return elem;
 }
开发者ID:purplecow,项目名称:AutoBroswer,代码行数:21,代码来源:HtmlUtil.cs

示例2: get_around

        /*
         *  Takes webdoc from control.webbrowser. also two int for x-y coordinates.
         *  It takes a point, and find any DOM objects around the point. (with bound of +- 10)
         *  Ultimately, it adds to hashtable dom_cord with
         *  the DOM element (href) as key
         *  position coordinate Point was value (cord_dom -> key: cord value: dom)
         *
         */
        private void get_around(IHTMLDocument2 webdoc, int xcord, int ycord)
        {
            for (int i = 0; i < 30; i+=3)
            {
                for (int j = 0; j < 30; j+=3)
                {
                    try
                    {
                        var obj_1 = webdoc.elementFromPoint(xcord + i, ycord + j).getAttribute("href");
                        var obj_2 = webdoc.elementFromPoint(xcord - i, ycord + j).getAttribute("href");
                        var obj_3 = webdoc.elementFromPoint(xcord + i, ycord - j).getAttribute("href");
                        var obj_4 = webdoc.elementFromPoint(xcord - i, ycord - j).getAttribute("href");

                        if (obj_1 is String)
                        {   if (obj_1.Length > 0)
                            {
                                Point ele_coord = new Point(xcord + i, ycord + j);
                                dom_cord.Add(obj_1, ele_coord);
                                cord_dom.Add(ele_coord, obj_1);
                            }
                        }
                        if (obj_2 is String)
                        {   if (obj_2.Length > 0)
                            {
                                Point ele_coord = new Point(xcord - i, ycord + j);
                                dom_cord.Add(obj_2, ele_coord);
                                cord_dom.Add(ele_coord, obj_2);
                            }
                        }
                        if (obj_3 is String)
                        {   if (obj_3.Length > 0)
                            {
                                Point ele_coord = new Point(xcord + i, ycord - j);
                                dom_cord.Add(obj_3, ele_coord);
                                cord_dom.Add(ele_coord, obj_3);
                            }
                        }
                        if (obj_4 is String)
                        {
                            if (obj_4.Length > 0)
                            {
                                Point ele_coord = new Point(xcord - i, ycord - j);
                                dom_cord.Add(obj_4, ele_coord);
                                cord_dom.Add(ele_coord, obj_4);
                            }
                        }
                    }
                    catch { }
                }
            }
        }
开发者ID:somang,项目名称:PDbrowser,代码行数:59,代码来源:SurfaceWindow1.xaml.cs


注:本文中的IHTMLDocument2.elementFromPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。