flash player embedded in asp page which is opened in webbrowser control

故事扮演 提交于 2019-12-20 06:43:22

问题


I am developing a windows application in C#.NET. In one of my winform I have added a WebBrowser control. In this webbrowser control I have opened an asp page from my local website. Now in this webpage there is one flash object which is used to play swf files. Now my question is can I access this control from my winform? If so then how? can u create a handler for that flash object?


回答1:


You can access the ActiveX's scripting interface from the element via the IHTMLObjectElement::object method. Search IShockwaveFlash in the microsoft.public.inetsdk.programming.webbrowser_ctl newsgroup for more information on this.

If you are using Windows Forms, html element's interface is exposed via HtmlElement.DomElement. You can add a reference to microsoft.mshtml and cast DomElement to IHTMLObjectElement, then obtain its object property and cast to IShockwaveFlash.

In ATL the code looks like this

#import   "flash.dll"   raw_interfaces_only

CComPtr<IDispatch>   htmlElement;   
CComPtr<IDispatch>   activeXObject;       
hr   =   GetElement(elementIdString,   &htmlElement);   
if   (htmlElement!= NULL)   
{   
    CComQIPtr<IHTMLObjectElement>   htmlObjectElement(htmlElement);
    if   (htmlObjectElement!= NULL)   
    {    
        htmlObjectElement->get_object(&activeXObject);   
        CComQIPtr<ShockwaveFlashObjects::IShockwaveFlash,   &IID_IUnknown>   flashViewer(spdispActiveXObject);     
        if(flashViewer!=NULL)
        {
            //do something on the flash
            CComBSTR movie;
            flashViewer->get_Movie(&movie);
        }
    }   
}   


来源:https://stackoverflow.com/questions/2749394/flash-player-embedded-in-asp-page-which-is-opened-in-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!