Re: firing events from server

Mark Burns <[email protected]> Tue, 28 May 2002 13:34:34 -0400
Newsgroups gmane.comp.windows.devel.vbcom
Message-ID <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAM4zfucMf7ki18ZSBD7ZyeGKEAAAQAAAAkcs1Rc8950mos8ysierkVgEAAAAA@quixnet.net>
Francis,

"Other post by Tinh"? I have not seen this.

Now, if I comprehend what you are doing, it is something like this:

==== myForm.frm ====
Dim WithEvents X as MyCOMWhatever

Sub TreeView1_NodeClick()

  Set X = getobject(blahblah...)
  <do stuff>    'X_SomeEvent is Triggered in your MyCOMWhatever
component
  Set X = Nothing

End Sub

Private Sub X_SomeEvent()       'code never runs
  <blah blah>
End Sub

==== end of myForm.Frm ====

...but it works okay when you do this:

==== myForm.Frm ====
Dim WithEvents X as MyCOMWhatever

Private Sub Form_Load()

  Set X = getobject(blah blah...)

End Sub

Sub TreeView1_NodeClick()

  <do stuff with X>     'X_SomeEvent is Triggered in your MyCOMWhatever
component

End Sub

Private Sub X_SomeEvent()       'code runs
  <blah blah>
End Sub

==== end of myForm.Frm ====

Right?
If so, I think this is as designed behavior due to the way COM has to
pass event handler notificaitons to object instances (in this case, the
form class instance is the event recipient).

Regards


> -----Original Message-----
> From: VBCOM [mailto:[email protected]] On Behalf Of
> Knebels, Francis
> Sent: Tuesday, May 28, 2002 1:16 PM
> To: [email protected]
> Subject: Re: [VBCOM] firing events from server
>
>
> this is a specific problem with object creation in the
> _NodeClick event and firing custom events.  The objects are
> setup correctly because if I change the object creation to
> form_load, it all works properly.  The variable is defined
> with "WithEvents" in the declaration section of a form.  I
> read the other post by Tinh and my project conforms to all
> the rules in his post.  I really believe that it has
> something to do with the treeview somehow.
>
> Francis X. Knebels
> Merck Vaccine Division
> WP97-3W507
> 215.652.7710
>
>
> -----Original Message-----
> From: Mark Burns [mailto:[email protected]]
> Sent: Tuesday, May 28, 2002 12:05 PM
> To: [email protected]
> Subject: Re: [VBCOM] firing events from server
>
>
> Francis,
>
> Are you using the remote COM object, within a class or within
> a VB module? In order to process events from a remote com
> object it must be declared WithEvents in a class module
> within your project.
>
> Unless I'm misunderstanding what you are asking, check out
> the VB online help for the WithEvents keyword.
> Like:
>
> ==== in a class module within your project ====
> Dim Withevents X as myComServerEventGenerationObject
>
> Private Sub/Function X_WhateverTheEventNameIsFromYourCOMServerObject()
>   <event handling code here>
> End Sub/Function
>
> Regards,
> - Mark
> Harrison Career Institute, Inc.
> Voorhees, NJ
> (856) 751-8181 x118
>
> > -----Original Message-----
> > From: VBCOM [mailto:[email protected]] On Behalf Of
> Knebels,
> > Francis
> > Sent: Tuesday, May 28, 2002 10:23 AM
> > To: [email protected]
> > Subject: [VBCOM] firing events from server
> >
> >
> > Has anyone run into a problem firing events from COM components.
> > Here's my scenario.
> >
> > I have a COM server that fires an event.  I have a standard
> EXE that
> > should catch the event.  the standard EXE has a treeview
> control and I
> > create an instance of the COM server in the NodeClick event of the
> > treeview.  Events from this object instance are never fired
> up to the
> > client.  If I take the object creation out of the NodeClick
> and put it
> > in the Form_load event, everything works properly.  Is this a known
> > issue?  I searched the MSKB but didn't find anything.
> >
> > Francis X. Knebels
> > Merck Vaccine Division
> > WP97-3W507
> > 215.652.7710
> >
> >
> > --------------------------------------------------------------
> > ----------------
> > Notice: This e-mail message, together with any attachments,
> contains
> > information of Merck & Co., Inc. (Whitehouse Station, New
> Jersey, USA)
> > that may be confidential, proprietary copyrighted and/or legally
> > privileged, and is intended solely for the use of the individual or
> > entity named on this message. If you are not the intended
> recipient,
> > and have received this message in error, please immediately
> > return this by e-mail and then delete it.
> >
> > ==============================================================
> > ================
> >
> > You can read messages from the VBCOM archive, unsubscribe
> from VBCOM,
> > or subscribe to other DevelopMentor lists at
> > http://discuss.develop.com.
> >
> >
>
> You can read messages from the VBCOM archive, unsubscribe
> from VBCOM, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>
>
> --------------------------------------------------------------
> ----------------
> Notice: This e-mail message, together with any attachments,
> contains information of Merck & Co., Inc. (Whitehouse
> Station, New Jersey, USA) that may be confidential,
> proprietary copyrighted and/or legally privileged, and is
> intended solely for the use of the individual or entity named
> on this message. If you are not the intended recipient, and
> have received this message in error, please immediately
> return this by e-mail and then delete it.
>
> ==============================================================
> ================
>
> You can read messages from the VBCOM archive, unsubscribe
> from VBCOM, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>
>

You can read messages from the VBCOM archive, unsubscribe from VBCOM, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.