Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Visual Basic 6 Problem

Question posted by: Darren Brook (Guest) on December 8th, 2006 02:25 PM
Does anyone know how to create an ActiveX EXE Server that raises events
which can be captured by muliple clients?

So, I have two applications that are both clients. I need to pass data via
the activex exe from one application to the other. The messages will be
"captured" as in the event handler, the code will check one of the
paramaters that contains a simple string that represents the recipients
"address" (these strings could be just "App1" and "App2".

I've tried to do this but it only raises the event in the application that
is sending the message. I need the event to be raised in both applications.

I have the ActiveX EXE properties set to "MultiUse" and using a Thread Pool
of 1.

Any help or advice would be very welcome as this is really causing me some
problems.

Many thanks,
Darren

--
Darren Brook
email: Join Bytes!








Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Dikkie Dik's Avatar
Dikkie Dik
Guest
n/a Posts
December 8th, 2006
05:25 PM
#2

Re: Visual Basic 6 Problem
Because of the troubles with "built-in" events, I switched to using
java-style events: The server defines an interface that standardizes the
sending and/or receiving of the messages. The clients then have objects
that implement that interface, which are handed to the server. The
server now communicates through those objects.

Best regards

Darren Brook wrote:
Quote:
Originally Posted by
Does anyone know how to create an ActiveX EXE Server that raises events
which can be captured by muliple clients?
>
So, I have two applications that are both clients. I need to pass data via
the activex exe from one application to the other. The messages will be
"captured" as in the event handler, the code will check one of the
paramaters that contains a simple string that represents the recipients
"address" (these strings could be just "App1" and "App2".
>
I've tried to do this but it only raises the event in the application that
is sending the message. I need the event to be raised in both applications.
>
I have the ActiveX EXE properties set to "MultiUse" and using a Thread Pool
of 1.
>
Any help or advice would be very welcome as this is really causing me some
problems.
>
Many thanks,
Darren
>


Darren Brook's Avatar
Darren Brook
Guest
n/a Posts
December 8th, 2006
10:55 PM
#3

Re: Visual Basic 6 Problem
When you said "troubles with built-in events", what did you mean?

Thanks,
Darren

"Dikkie Dik" <nospam@nospam.orgwrote in message
news:4579b32f$0$8902$bf4948fe@news.tele2.nl...
Quote:
Originally Posted by
Because of the troubles with "built-in" events, I switched to using
java-style events: The server defines an interface that standardizes the
sending and/or receiving of the messages. The clients then have objects
that implement that interface, which are handed to the server. The server
now communicates through those objects.
>
Best regards
>
Darren Brook wrote:
Quote:
Originally Posted by
>Does anyone know how to create an ActiveX EXE Server that raises events
>which can be captured by muliple clients?
>>
>So, I have two applications that are both clients. I need to pass data
>via
>the activex exe from one application to the other. The messages will be
>"captured" as in the event handler, the code will check one of the
>paramaters that contains a simple string that represents the recipients
>"address" (these strings could be just "App1" and "App2".
>>
>I've tried to do this but it only raises the event in the application
>that
>is sending the message. I need the event to be raised in both
>applications.
>>
>I have the ActiveX EXE properties set to "MultiUse" and using a Thread
>Pool
>of 1.
>>
>Any help or advice would be very welcome as this is really causing me
>some
>problems.
>>
>Many thanks,
>Darren
>>




Steve Gerrard's Avatar
Steve Gerrard
Guest
n/a Posts
December 9th, 2006
01:35 AM
#4

Re: Visual Basic 6 Problem

"Darren Brook" <D_Brook@btinternet.comwrote in message
news:3vCdnR_nm4RCFeTYnZ2dnUVZ8tuknZ2d@bt.com...
Quote:
Originally Posted by
Does anyone know how to create an ActiveX EXE Server that raises events
which can be captured by muliple clients?
>


I could post the sample code, but you might as well look at the article
yourself.
This is a link to Sharing the CoffeeMonitor, which is step 7 in the VB tutorial
on Creating an Activex Exe Component.

http://msdn.microsoft.com/library/e...ffeemonitor.asp

In summary, it says:

For two apps to both receive the events, they must get a reference to a shared
object, not each create their own new object.

To do this, you create a Connector class. Each app creates its own Connector
object, and the connector has a method for getting a reference to the one shared
RealClass object (the CoffeeMonitor in the example).

The real object is created when the first connector is created, and terminated
when the last connector is terminated. It is set to PublicNotCreatable, so that
each app is forced to use the Connector to get to it.

In each app, the code looks something like

Dim WithEvents RealObj As RealClass
Dim Conn As Connector
Set Conn = New Connector
Set RealObj = Conn.RealObject




Ralph's Avatar
Ralph
Guest
n/a Posts
December 9th, 2006
03:35 AM
#5

Re: Visual Basic 6 Problem

"Darren Brook" <D_Brook@btinternet.comwrote in message
news:3vCdnR_nm4RCFeTYnZ2dnUVZ8tuknZ2d@bt.com...
Quote:
Originally Posted by
Does anyone know how to create an ActiveX EXE Server that raises events
which can be captured by muliple clients?
>
So, I have two applications that are both clients. I need to pass data

via
Quote:
Originally Posted by
the activex exe from one application to the other. The messages will be
"captured" as in the event handler, the code will check one of the
paramaters that contains a simple string that represents the recipients
"address" (these strings could be just "App1" and "App2".
>
I've tried to do this but it only raises the event in the application that
is sending the message. I need the event to be raised in both

applications.
Quote:
Originally Posted by
>
I have the ActiveX EXE properties set to "MultiUse" and using a Thread

Pool
Quote:
Originally Posted by
of 1.
>
Any help or advice would be very welcome as this is really causing me some
problems.
>
Many thanks,
Darren
>


Well there is always DDE. It is somewhat out of favor, but is built into VB
and very simple to implement.

-ralph



Dikkie Dik's Avatar
Dikkie Dik
Guest
n/a Posts
December 9th, 2006
04:45 PM
#6

Re: Visual Basic 6 Problem
When you said "troubles with built-in events", what did you mean?

Sometimes, they just don't fire. When single stepping through the code,
the RaiseEvent command is executed and there is a WithEvents variable
containing an object that should catch it, but nothing is caught. I
could not extract a pattern in when it does work, or when it doesn't.
Mind you, this only happens (so far) when trying to catch events from
objects from another project.


Best regards

 
Not the answer you were looking for? Post your question . . .
182,081 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors