• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

Adding an interface to an even class

Started by Edwin Knoppert, August 24, 2009, 12:02:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Edwin Knoppert

The suggestion to append a method to eventclass to pass the control's hWnd for example is handy but i am a bit worried about the member indexes i see in some interfaces.
It may conflict?

Well, my idea was to append another interface to the class and create a reference to that but, the queryinterface may never recognize this interface since the code is in Windows (like for the webcontrol).

Is it possible to bypass this queryinterface and share the same class instance data with my new interface?
I could temporary use an alternative iunknown but that i am not sure these offsets are readonly + i would not like to do it this way.

Edwin Knoppert

The title threw away the 't'

"it wasn't me" :)

José Roca

Quote
The suggestion to append a method to eventclass to pass the control's hWnd for example is handy but i am a bit worried about the member indexes i see in some interfaces.
It may conflict?

Just add to it a number that isn't used by the events interface, e.g. <11111111>.

Edwin Knoppert

Yes but is adding an interface a possibility?

José Roca

 
You can add whatever you want. What you can't add is another dispatch interface because only one is allowed per class, but you can add a custom interface.

Event classes are like any other class. The differences, with the PB implementation, is that if a class is declared AS EVENT, then PB will flag it as such in the type library. Another difference is that you can't return a result because Automation only languages don't support it. But everything else is the same: Create and Destroy will be called; QueryInterface will work; instance data will be shared, etc.

You even can use an standard class for events sink if you want, and you can even make it to inherit from IUnknown instead of IDispatch, in which case you will have to process Invoke yourself.

José Roca

 
And last, but not the least, you can even use a PB event class and make it to inherit from IUnknown instead of IDispatch. This is currently needed to deal with events of components such MSWORD that send named parameters. See my last post in this thread:

http://www.powerbasic.com/support/pbforums/showthread.php?t=39469&highlight=named+parameters

I advice you to read all the thread. It is quite illustrative.