I have seen WithEvents used before and I understand it somewhat but I am looking for some clarification. How far can its use be extended? Can I declare an object WithEvents without knowing what will be in it?
I am working on making a custom control and I have an Init() method. In that method you declare which control on the form you want to link my control to. I know the control will always have a Resize event, but I don't always know what the event will be. Is there a way to use WithEvents to access the Resize event?
I experimented a little and found that doing WithEvents with an Object doesn't work because you have to specify a specific control. Is there any way to get access to the events of an object without knowing what object it will be, but knowing it will have a Resize event?
The events are part of the class's interface, so you can't declare a generic Object WithEvents. What you can do, I think, is declare an instance interface class WithEvents and make all your classes Implement that interface. Pop your events in there and it should work (assuming VB6 handles interfaces the way I think).
The events are part of the class's interface, so you can't declare a generic Object WithEvents. What you can do, I think, is declare an instance interface class WithEvents and make all your classes Implement that interface. Pop your events in there and it should work (assuming VB6 handles interfaces the way I think).
The events are part of the class's interface, so you can't declare a generic Object WithEvents. What you can do, I think, is declare an instance interface class WithEvents and make all your classes Implement that interface. Pop your events in there and it should work (assuming VB6 handles interfaces the way I think).
As far as I understood the whole event stuff, interfaces which support events
only implement IConnectionPointContainer, but the events have their own interface.
So what you do if you want events:
get IConnectionPointContainer from the interface,
take the first IConnectionPoint returned by IConnectionPointContainer.EnumConnectionPoints,
create a new interface which implements IDispatch (event sink),
advise your event sink to IConnectionPoint,
and capture events through IDispatch.Invoke, which the interface will call everytime an event get's raised.