Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Paul Squires on March 24, 2009, 01:31:22 AM

Title: Multiple COM instances - how to tell them apart?
Post by: Paul Squires on March 24, 2009, 01:31:22 AM
Hi,

I am working on COM/ActiveX integration using José's new includes and OLE Container. I am also using José's TypeLib Browser instead of PB's COM Browser.

For objects that have Events, what is the best way to determine which control has fired the event? Say, that I have 2 masked edit controls on the dialog, I point both controls to the same events code.

(summary of the code):

hMaskedEd and hMaskedEd2 are window handles

pMaskedEd = OC_GetDispatch(hMaskedEd)
pMaskedEvents = CLASS "CMaskEdBoxEvents"
EVENTS FROM pMaskedEd CALL pMaskedEvents
pMaskedEd = NOTHING

pMaskedEd = OC_GetDispatch(hMaskedEd2)
EVENTS FROM pMaskedEd CALL pMaskedEvents
pMaskedEd = NOTHING


How can I put code in the "Change" event for the control that determines which masked edit control has fired the Change event?


INTERFACE MaskEdBoxEventsImpl GUID$("{C932BA87-4374-101B-A56C-00AA003668DC}") AS EVENT

  INHERIT IDispatch

   ' =====================================================================================
   METHOD Change <1>

     ' *** Insert your code here ***
     OutputDebugString FUNCNAME$
     
   END METHOD



Sorry if this sounds like an easy question - maybe I am missing something really simple?  :)


Title: Re: Multiple COM instances - how to tell them apart?
Post by: José Roca on March 24, 2009, 02:29:24 AM
 
The only way would be to have a separate event class for each instance of the control.
Title: Re: Multiple COM instances - how to tell them apart?
Post by: Paul Squires on March 24, 2009, 03:05:16 AM
Thanks José  :)