Board index » cppbuilder » Firing COM Events in BCB4

Firing COM Events in BCB4

Hi,

I'm usin BCB 4 in Windows NT 4.0 in order to server Events using COM
technology.
All is OK Firing Events in the Principal Events using (for example OnClick
events),
like this:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
TTPBXImpl * pObj;

for(int i = 0;i<Objetos->Count;i++)
{
        pObj = (TTPBXImpl *)Objetos->Items[i];
        pObj->DisparaOnAgentesLibres(Edit1->Text,Edit2->Text.ToInt()); //
Fire Event to all COM Clients

Quote
}

But I have a Thread Waiting for custom events. This custom events must
redirected to COM Clientes.

I 've put this code in this thread, like this:

...
...

// Same Polling event in the Thread (not the principal Thread):

TTPBXImpl * pObj;

for(int i = 0;i<Objetos->Count;i++)
{
        pObj = (TTPBXImpl *)Objetos->Items[i];
        pObj->DisparaOnAgentesLibres(WideString("Event"),evento); // Fire
Event to all COM Clients

Quote
}

....
....
next to event .... to pool
 .. and so on

////////7

But NOTHING Happen. In the Client Side , nothing !!!!, in the Server Side,
execute DisparaOnAgentesLibres and return no Error.

What's wrong ?

Luis Cataln

begin 666 luis catalan hernandez.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..FAE<FYA;F1E>CML=6ES.V-A
M=&%L86X-"D9..FQU:7,@8V%T86QA;B!H97)N86YD97H-"E)%5CHQ.3DY,3$Q
6.%0Q.#(Q,#%:#0I%3D0Z5D-!4D0-"@``
`
end

 

Re:Firing COM Events in BCB4


You have to perform interface marshaling of the event sink interfaces from
the main thread to your firing thread. You can use the
CoMarshalInterThreadInterfaceInStream and the CoGetInterfaceAndReleaseStream
APIs.

There's an example of this in David Platt's "Essence of COM with ActiveX"

have fun
--
Binh Ly
Visit my COM Notes at http://www.castle.net/~bly/com

Quote
luis_catalan <l...@cestel.es> wrote in message

news:811fpr$9fb4@forums.borland.com...
Quote
> Hi,

> I'm usin BCB 4 in Windows NT 4.0 in order to server Events using COM
> technology.
> All is OK Firing Events in the Principal Events using (for example OnClick
> events),
> like this:

> void __fastcall TForm1::Button2Click(TObject *Sender)
> {
> TTPBXImpl * pObj;

> for(int i = 0;i<Objetos->Count;i++)
> {
>         pObj = (TTPBXImpl *)Objetos->Items[i];
>         pObj->DisparaOnAgentesLibres(Edit1->Text,Edit2->Text.ToInt()); //
> Fire Event to all COM Clients

> }

> But I have a Thread Waiting for custom events. This custom events must
> redirected to COM Clientes.

> I 've put this code in this thread, like this:

> ...
> ...

> // Same Polling event in the Thread (not the principal Thread):

> TTPBXImpl * pObj;

> for(int i = 0;i<Objetos->Count;i++)
> {
>         pObj = (TTPBXImpl *)Objetos->Items[i];
>         pObj->DisparaOnAgentesLibres(WideString("Event"),evento); // Fire
> Event to all COM Clients

> }

> ....
> ....
> next to event .... to pool
>  .. and so on

> ////////7

> But NOTHING Happen. In the Client Side , nothing !!!!, in the Server Side,
> execute DisparaOnAgentesLibres and return no Error.

> What's wrong ?

> Luis Cataln

Other Threads