Invoke events from .Net Activex control to JavaScript.

238 views
Skip to first unread message

Christopher

unread,
Sep 10, 2013, 5:42:03 AM9/10/13
to ff-acti...@googlegroups.com
Hi Leeor Aharon,

First of all many many thanks for your ffactivex plugin. I have download the plugin source code and created a new plugin dll and hosted. Everything works well.

 

I am creating an application for web scanning. I am able to call all methods and properties from JavaScript to ActiveX control from Firefox browser. But i am unable to invoke events from ActiveX to JavaScript. 

 

Please find the part of my .Net ActiveX code below which i have implemented to handle the events. This is working well with IE browser. Could you please help me to resolve this issue?


Event Interface:

namespace ScanControl.Interfaces
{
    #region IUserEvents
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("7A101534-5615-F389-1015-AF97F3898E73")]
    [ComVisible(true)]
    public interface IUserEvents
    {
        [DispId(0x60020000)]
        void event_OnIAfterAcquire();

    }

    #endregion //IUserEvents
}
-----------------------------------------------------------------------------

ActiveX Component:

 [ComVisible(true)]
    [Guid("DA590DB2-FDA5-4FBE-8F68-7C4E553A4FBE")]
    [ProgId("ScanControl.ScanActiveX")]
    [ComDefaultInterface(typeof(IScanActiveX))]
    [ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof(IUserEvents))]
    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    public partial class ScanActiveX : UserControl, IScanActiveX, IObjectSafety
    {

        public delegate void EventAfterAcquire();

        public event EventAfterAcquire event_OnIAfterAcquire;
   }

-----------------------------------------------------------------------------------------------------------------------------------

From webpage Javascript file:

function Pageonload()
{
        strObject = " <object id='WebScan' type='application/scanactivex' clsid='{DA590DB2-FDA5-4FBE-8F68-7C4E553A4FBE}' "
        strObject += " height='950px' width ='1100px' event_OnIAfterAcquire='ActiveXControl_OnPostTransfer' >"
        strObject += " </object> ";
}

 function ActiveXControl_OnPostTransfer() {
      alert("Transfered"); 
}

Thanks,
Christopher

Leeor Aharon

unread,
Sep 10, 2013, 5:04:49 PM9/10/13
to ff-activex-host
Hi Christopher,

I'm glad to hear that you found my plugin helpful.

Have you tried activating debug logging? Your code looks good, there's nothing too obvious that might indicate what the problem might be.

Regards,
Leeor.


--
You received this message because you are subscribed to the Google Groups "ff-activex-host" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ff-activex-ho...@googlegroups.com.
To post to this group, send email to ff-acti...@googlegroups.com.
Visit this group at http://groups.google.com/group/ff-activex-host.
For more options, visit https://groups.google.com/groups/opt_out.

Christopher

unread,
Sep 11, 2013, 5:41:29 AM9/11/13
to ff-acti...@googlegroups.com
Hi Leeor,

Thanks a lot for your prompt reply. Now everything is working fine. I have done little changes on my event name. I have remove "event_" from my event name. I am placing my modified code below. It may useful to other people who are all finding the same kind of issues. Once again thank you very much for your wonderful plugin.

Event Interface:

namespace ScanControl.Interfaces
{
    #region IUserEvents
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [Guid("7A101534-5615-F389-1015-AF97F3898E73")]
    [ComVisible(true)]
    public interface IUserEvents
    {
        [DispId(0x60020000)]
        void OnAfterAcquire();

    }

    #endregion //IUserEvents
}
-----------------------------------------------------------------------------

ActiveX Component:

 [ComVisible(true)]
    [Guid("DA590DB2-FDA5-4FBE-8F68-7C4E553A4FBE")]
    [ProgId("ScanControl.ScanActiveX")]
    [ComDefaultInterface(typeof(IScanActiveX))]
    [ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof(IUserEvents))]
    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    public partial class ScanActiveX : UserControl, IScanActiveX, IObjectSafety
    {

        public delegate void EventAfterAcquire();

        public event EventAfterAcquire OnAfterAcquire;

        void RaiseAfterAcquire()
        {
            if (OnAfterAcquire != null)
                OnAfterAcquire();
        }

   }

Use RaiseAfterAcquire() method wherever need to raise the events from activex control.

-----------------------------------------------------------------------------------------------------------------------------------

From webpage Javascript file:

function Pageonload()
{
        strObject = " <object id='WebScan' type='application/scanactivex' clsid='{DA590DB2-FDA5-4FBE-8F68-7C4E553A4FBE}' "
        strObject += " height='950px' width ='1100px' event_OnAfterAcquire='ActiveXControl_OnPostTransfer' >"
        strObject += " </object> ";
}

 function ActiveXControl_OnPostTransfer() {
      alert("Transfered"); 
}

Thanks,
Christopher

Christopher

unread,
Sep 11, 2013, 7:54:26 AM9/11/13
to ff-acti...@googlegroups.com
Hi Leeor,

Can i use the same plugin code for Chrome browser also? If yes, could you please tell me what should i make the changes for working this plugin code for Chrome? If i make same dll for FF and Chrome then it will be very helpful to make a single installation package. Because i don't want to make each installation package for each browser.

Thanks,
Christopher 

Leeor Aharon

unread,
Sep 11, 2013, 8:12:53 AM9/11/13
to ff-activex-host
Hi Christopher,

The HTML/JS code needs not change when working in Chrome, it's exactly the same as Firefox (small differences might exist in the way the different browsers create and destroy native code objects).

Packaging the plugin is a different matter. You can create the Chrome package from within Chrome's Extensions page.

Regards,
Leeor.


--

Christopher

unread,
Sep 11, 2013, 3:20:10 PM9/11/13
to ff-acti...@googlegroups.com
Hi Leeor,

Thanks for your reply. I am sorry to trouble you again ;-)

Can you please tell me the exact modification that may be require that plugin to work in Chrome browser?

Thanks,
Christopher

Leeor Aharon

unread,
Sep 12, 2013, 3:48:52 AM9/12/13
to ff-activex-host
Hi Christopher,

No such modifications are required.

Leeor.


--

朱竞光

unread,
Sep 13, 2013, 6:53:40 AM9/13/13
to ff-acti...@googlegroups.com
hi, now i use the np-activex plugins,but chrome can't  Invoke events from VC ATL control to JavaScript.
and  IE  is successful,thank you for  give me some information.


and  I  see in 




在 2013年9月12日星期四UTC+8下午3时48分52秒,Leeor Aharon写道:
Reply all
Reply to author
Forward
0 new messages