views:

156

answers:

1

I am develoing 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  A: 

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);
        }
    }   
}   
Sheng Jiang 蒋晟
Hey Thanks Sheng for your reply.Can u plz explain me with some code or some of the useful links. I dont have idea about it and dont know how to do it in C#.NET.Thanks in advance...
Prit
Thank you so much Sheng. I think it would be helpful for me...
Prit