WebBrowser控件:如何获取embed对象的参考? [英] WebBrowser control : how to get a reference for an embed objet ?

查看:87
本文介绍了WebBrowser控件:如何获取embed对象的参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的目标是与嵌入在网页中的Flash对象进行交互。

My aim is to interact with a Flash Object embed in a Web Page.

我尝试使用C#应用程序托管WebBrowser控件,导航到包含flash对象(如电影)的网页,但HtmlElement和HtmlDocument不允许转换< objet>标记到.NET Flash对象.....

I tried with a C# app that host a WebBrowser control, navigate to a web page containing a flash object (like a movie), but HtmlElement and HtmlDocument does not permit to transform the <objet> tag to a .NET Flash object .....

我知道我可以直接使用ShockwaveFlash ActiveX在.NET表单中,但根据我的需要,swf文件应保留在其上下文(网页)中。

I know that I can use the ShockwaveFlash ActiveX directly in a .NET form, but for my needs, the swf file should remain in its context (the web page).

如何获得"引用"?这个Flash对象?我想从我的C#应用​​程序与它进行交互。

How can I get a "reference" to this Flash object ? I would like to interact with it from my C# app.

我在互联网上搜索了这么多个小时,我没有找到任何有意解决这个问题的东西。

I was searching so many hours on the Internet, I do not found anything interessting to solve this problem.

我甚至试图用C ++做到这一点:获取ActiveX的句柄(没关系,和Spy ++找到的句柄一样)但我无法将其转换为Windows窗体控件,因为Control.FromHandle()不允许这样.... ....

I even tried to do it with C++ : getting the handle of the ActiveX (it's OK, same handle as Spy++ find) but I cannot transform it to a Windows Forms Control because Control.FromHandle() does not permit this....

有人请一个想法吗?

干杯,

Jack

推荐答案

看看这是否有助于我找到对象的问题  http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral / thread / f73ce91d-aaa5-4582-885c-ceb64dbed37e?prof = required

var chkbox = Page.GetControl(ConfigNameAndControlName) as CheckBox;

publicstaticclass MyExtensionMethods {

/// <summary>
        /// Get a Control Object
        /// </summary>
        /// <param name="id">The string representation of the ID.</param>
        /// <returns>The Control Object found or null</returns>
        public static Control GetControl(this Control control, string id)
        {
            //Returns The Control Object or null
            return control.Controls.Flatten(c => c.ID == id).SingleOrDefault(); //Return the first result or null
        }
 
        //Helper to GetControl
        public static IEnumerable<Control> Flatten(this ControlCollection controls, Func<Control, bool> predicate)
        {
            List<Control> list = new List<Control>();
            controls.Traverse(c => { if (predicate(c)) list.Add(c); }); //predicate is c.ID == id
            return list;
        }
 
        //Helper to Flatten for GetControl and Flatten for GetControls
        public static void Traverse(this ControlCollection controls, Action<Control> action)
        {
            foreach (Control control in controls)
            {
                action(control); //action is if(predicate(c)) then list.Add(c)
                if (control.HasControls()) //If the control has children then travers them, recursive search
                {
                    control.Controls.Traverse(action);
                }
            }
        }
 
        /// <summary>
        /// Get Control Objects in a List Array.
        /// </summary>
        /// <returns>Array of Controls</returns>
        public static IEnumerable<Control> GetControls(this Control control)
        {
            return control.Controls.Flatten();
        }
 
        //Helper to GetControls
        public static IEnumerable<Control> Flatten(this ControlCollection controls)
        {
            List<Control> list = new List<Control>();
            controls.Traverse(c => list.Add(c));
            return list;
        }





这篇关于WebBrowser控件:如何获取embed对象的参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆