0

In my ActiveX Control, using the Class Wizard, I added a custom event named OutboundCallStateChanged. It generated the following in my OLEControl class:

.h file

    class CIVR60Ctrl : public COleControl
    {
    ...
    public:

// Event maps
        //{{AFX_EVENT(CIVR60Ctrl)
        void FireOutboundCallStateChanged()
            {FireEvent(eventidOutboundCallStateChanged,EVENT_PARAM(VTS_NONE));}
        //}}AFX_EVENT
        DECLARE_EVENT_MAP()
    ...
    }

    // Dispatch and event IDs
    public:
        CMainDialog m_MainDialog;
        enum {
        //{{AFX_DISP_ID(CIVR60Ctrl)
        dispidToolTipText = 1L,
        dispidDial = 4L,
        dispidGetOutboundCallState = 6L,
        ...  
        dispidGetUserStatus = 13L,
        eventidOutboundCallStateChanged = 1L,
        //}}AFX_DISP_ID
        };
    };

In the .cpp file:

// Event map

BEGIN_EVENT_MAP(CIVR60Ctrl, COleControl)
    //{{AFX_EVENT_MAP(CIVR60Ctrl)
    EVENT_CUSTOM("OutboundCallStateChanged", FireOutboundCallStateChanged, VTS_NONE)
    //}}AFX_EVENT_MAP
END_EVENT_MAP()

Ok, very nice. Now when I try to use that function from inside another class (which I think is a COM object) like this:

pMainClass->p_IVRCtrl->FireOutboundCallStateChanged();

IE8 just crashes and tells me it recovered the tab. When I fire it inside the IVR60Ctrl class though; I think it's working.

In the first case I think the call throws an exception. I don't know what kind of; I only could catch it with catch(...). Can anyone tell me why it could be not working; and what type of exception would this throw so that I can catch it?

EDIT: I managed to avoid the exception by calling FireOutboundCallStateChanged() from a new thread. Now it doesn't crash but I'm not sure if the event is really being raised in IE when I fire it. How can I check if the event arrives IE?

Now in the .html file I try the following:

        <OBJECT name="ivr" ID="IVR601" WIDTH=973 HEIGHT=52 align="top"
            CODEBASE="IVR60.ocx"
            CLASSID="CLSID:01B5BC0F-A51D-4C47-B3E9-3DA1099750CE"
style="position:absolute; top:2px; left:10px;">
            <PARAM NAME="_Version" VALUE="65536">
            <PARAM NAME="_ExtentX" VALUE="23865">
            <PARAM NAME="_ExtentY" VALUE="2164">
            <PARAM NAME="_StockProps" VALUE="0">
        </OBJECT> 
        <script type="text/javascript">
            var ocx = IVR601;       

            function ivr::OutboundCallStateChanged(){
                alert("fired");
            }
        </script> 

But when I call FireOutboundCallStateChanged() from the ActiveX object, I don't get the alert so I don't know if I can't catch the event or if it isn't raised at all.

Halo
  • 1,524
  • 3
  • 24
  • 39
  • I would expect IE to own the instance of CIVR60Ctrl and likewise be the connection point recipient of the events fired by the instance. How does pMainClass initialize the p_IVRCtrl pointer? – bvj Nov 30 '13 at 22:54
  • I actually managed to avoid the exception by calling that event from a new thread. Now it doesn't crash but I'm not sure if the event is really being raised in IE when I fire it. How can I check if the event arrives IE? – Halo Nov 30 '13 at 23:04

0 Answers0