JScript and COM Events 
Author Message
 JScript and COM Events

Does anyone know how to catch COM events using JScript?  I
found one example of it using ActiveXObject, but it was
not very helpful, I'm looking for a better example from
someone.  Can someone give me and example?

Thanks,
Craig



Sat, 09 Oct 2004 08:22:17 GMT  
 JScript and COM Events

Quote:
> Does anyone know how to catch COM events using JScript?  I
> found one example of it using ActiveXObject, but it was
> not very helpful, I'm looking for a better example from
> someone.  Can someone give me and example?

Not until you clarify what you intend as the host for the script...IE?...WSH?...HTA...ASP?

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sat, 09 Oct 2004 09:16:59 GMT  
 JScript and COM Events

     Sorry about that, I was in a rush.  The host is IE 6.  My project
is two-way communication (web browser to an Out-Of-Process COM object
and Out-Of-Process COM object back to Web Browser).  I'm currently using
Connections Points between standalone COM apps.  Now all I need is
someway to fire events back, from my COM Apps, Out-Of-Process COM
objects to the web browser and I'm finished.

Thank you,
Craig Beasley

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 10 Oct 2004 00:42:43 GMT  
 JScript and COM Events

Quote:
>      Sorry about that, I was in a rush.  The host is IE 6.  My project
> is two-way communication (web browser to an Out-Of-Process COM object
> and Out-Of-Process COM object back to Web Browser).  I'm currently using
> Connections Points between standalone COM apps.  Now all I need is
> someway to fire events back, from my COM Apps, Out-Of-Process COM
> objects to the web browser and I'm finished.

Scripting Events
http://msdn.microsoft.com/library/en-us/dnclinic/html/scripting040920...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sun, 10 Oct 2004 02:59:55 GMT  
 JScript and COM Events
Michael,
     Thanks, but I have already visited this site and found it not very
useful.  For example the examples at the bottom of the page refers to:

set myorder3 = createobject("ordersystem.clsorder")

wscript.connectobject myorder3,"myorder3_"

myorder3.neworder(1)
sub myorder3_onNew()
   Wscript.echo "new order received from myorder3"
end sub

The parameter inside createobject is a progid and my event classes in my
Out-Of-Process COM object do not have progids.  So what do I do?  Also
there is not any examples of using COM events with JScript on the page.
Do you have any examples that you might have done?

Thanks,
Craig

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 10 Oct 2004 03:42:36 GMT  
 JScript and COM Events

Quote:
>      Thanks, but I have already visited this site and found it not very
> useful.  For example the examples at the bottom of the page refers to:

> set myorder3 = createobject("ordersystem.clsorder")

> wscript.connectobject myorder3,"myorder3_"

> myorder3.neworder(1)
> sub myorder3_onNew()
>    Wscript.echo "new order received from myorder3"
> end sub

> The parameter inside createobject is a progid and my event classes in my
> Out-Of-Process COM object do not have progids.  So what do I do?  Also
> there is not any examples of using COM events with JScript on the page.
> Do you have any examples that you might have done?

How is the JScript hosted - I assume a host that supports <object> elements?  IE??? WSH/WSF??? WSC??? ...???  But then Andrew's article covered all of these...

How are instances of your progid-less components created?

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sun, 10 Oct 2004 04:12:41 GMT  
 JScript and COM Events
Michael,
    Here is code s{*filter*}t from my interface and events class taken out
of my Out-Of-Process COM object.

// Communications.h : Declaration of the CCommunications

#pragma once
#include "resource.h"       // main symbols

#include "Events.h"

[
        object,
        uuid("B5406F66-B3F1-43EF-B5C2-3E1CEB9EB904"),
        dual,   helpstring("ICommunications Interface"),
        pointer_default(unique)
]
__interface ICommunications : IDispatch
{
        [id(1), helpstring("method AddProjectInfo")] HRESULT
AddProjectInfo([in] BSTR bInfo);
        [id(2), helpstring("method GetProjectInfo")] HRESULT
GetProjectInfo([out,retval] VARIANT* pvProjectInfo);
        [id(3), helpstring("method RemoveAllProjectInfo")] HRESULT
RemoveAllProjectInfo(void);
        [id(4), helpstring("method SendProjectInfo")] HRESULT
SendProjectInfo(void);
        [id(5), helpstring("method ChangeProjectInfo")] HRESULT
ChangeProjectInfo([in] ULONG nIndex, [in] BSTR bInfo);
        [id(6), helpstring("method RemoveProjectInfo")] HRESULT
RemoveProjectInfo([in] ULONG nIndex);
        [id(7), helpstring("method GetProjectStatus")] HRESULT
GetProjectStatus([out,retval] SHORT* nStatus);

Quote:
};

// _ICommunicationsEvents
[
        dispinterface,
        uuid("2B3EFA3D-C323-4590-8C45-E877B7B102FA"),
        helpstring("_ICommunicationsEvents Interface")
]

__interface _ICommunicationsEvents
{
        [id(1), helpstring("method Status")] HRESULT Status([in] USHORT
nStatus);

Quote:
};

// CCommunications

[
        coclass,
        threading("apartment"),
        event_source("com"),
        vi_progid("COMMiddleMan.Communications"),
        progid("COMMiddleMan.Communications.1"),
        version(1.0),
        uuid("74C07192-60FD-4DBC-BA86-36C252B21339"),
        helpstring("Communications Class")
]
class ATL_NO_VTABLE CCommunications :
        public ICommunications
{
public:
        CCommunications()
                : m_nStatus(0)
        {
        }

        __event __interface _ICommunicationsEvents;

        DECLARE_PROTECT_FINAL_CONSTRUCT()

        HRESULT FinalConstruct()
        {
                return S_OK;
        }

        void FinalRelease()
        {
        }

public:
        STDMETHOD(AddProjectInfo)(BSTR bInfo);
        STDMETHOD(GetProjectInfo)(VARIANT* pvProjectInfo);
        STDMETHOD(RemoveAllProjectInfo)(void);
        STDMETHOD(SendProjectInfo)(void);
private:

public:
        int FindAppToRun(void);
        CString RemovePre(CString sPhrase);
private:
        CComObject<CStandAlongSink> *m_isptrStandAlongSink;
        IInfoExchangerPtr m_pInfo;
        CComSafeArray<VARIANT> m_saProjectInfo;
public:
        STDMETHOD(ChangeProjectInfo)(ULONG nIndex, BSTR bInfo);
        STDMETHOD(RemoveProjectInfo)(ULONG nIndex);
        STDMETHOD(GetProjectStatus)(SHORT* nStatus);
        short m_nStatus;

Quote:
};

The COM interface here is ICommunications and the events interface is
ICommunicationsEvents.  The ICommunications progid is
COMMiddleMan.Communications, but the events interface doesn't have one.
In all the examples that I have seen using <object>, ActiveXObject
(functions, tags), they take a progid.  I may be wrong but thats why I'm
seeking help.  I'm guessing that since my events interface is not an
interface that can be implemented directly from the outside(Using some
other program or script), that I have to find a way to advise the script
of incoming events.

Thanks again,
Craig

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Sun, 10 Oct 2004 04:46:25 GMT  
 JScript and COM Events

Quote:
>     Here is code s{*filter*}t from my interface and events class taken out
> of my Out-Of-Process COM object.

Sorry, all that C++ code is lost on me ;-)...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sun, 10 Oct 2004 05:56:48 GMT  
 JScript and COM Events
Thanks anyway.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 10 Oct 2004 06:02:20 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Sinking COM Events in JScript

2. accessing COM automation events (TAPI 3.0) from JScript

3. HowTo: Sinking Events in JScript from a COM Object

4. COM Event Handlers with JScript

5. JScript + COM + Events

6. how to handle com events within a jscript but not a wscript environment

7. How to handle COM events in JScript (IE) ?

8. ATL COM Component firing events into VBScript event sink

9. JScript event handler for ActiveX DLL events within IE

10. VBScript, COM Events & Safe Arrays

11. Getting events from out of process COM objects?

 

 
Powered by phpBB® Forum Software