Hi Everyone,
I'm in the process of writing a DLL library, the idea of which is to watch controls for various events (let's keep this simple and just say Focus for now)... I've got the code sorted out in terms of tracking the events that we'd like to watch, but the actual watching is proving troublesome!
My first attempt at this was to declare a seperate class to wrap each class of control I was interested in, and give these wrapper classes a common interface. My focus manager would then be free to store these wrapper objects - and use the common interface to be able to get back to the underlying control. All seemed well.
In terms of watching for the events, each wrapper would hold a reference for the associated control type declared using "WithEvents" - therefore allowing my wrapper object to read the event of the associated control. My first few tests were wonderfully successful...
Unfortunately however, I have found that it doesn't work with elements that are in control arrays - because when you think about it those elements are trying to add an "Index" argument to the event signatures, which is not supported by the events on my reference within the wrapper...
I've come across a class called VBControlExtender, and if I could only get it to work this could solve all my problems - as well as meaning I would only need one, single, solitary wrapper class for everything - which has a certain appeal.
My question then (here it comes) - if I have say a Textbox that was added to a form at DESIGN time - how do I get my hands on a corresponding VBControlExtender object for it. The only examples I've seen thus far involve the creation of objects using Form.Controls.Add - ie dynamic - which isn't what I'm trying to do...
My thanks in anticipation of anyone who feels like providing a burst of inspiration...
Martin
I'm in the process of writing a DLL library, the idea of which is to watch controls for various events (let's keep this simple and just say Focus for now)... I've got the code sorted out in terms of tracking the events that we'd like to watch, but the actual watching is proving troublesome!
My first attempt at this was to declare a seperate class to wrap each class of control I was interested in, and give these wrapper classes a common interface. My focus manager would then be free to store these wrapper objects - and use the common interface to be able to get back to the underlying control. All seemed well.
In terms of watching for the events, each wrapper would hold a reference for the associated control type declared using "WithEvents" - therefore allowing my wrapper object to read the event of the associated control. My first few tests were wonderfully successful...
Unfortunately however, I have found that it doesn't work with elements that are in control arrays - because when you think about it those elements are trying to add an "Index" argument to the event signatures, which is not supported by the events on my reference within the wrapper...
I've come across a class called VBControlExtender, and if I could only get it to work this could solve all my problems - as well as meaning I would only need one, single, solitary wrapper class for everything - which has a certain appeal.
My question then (here it comes) - if I have say a Textbox that was added to a form at DESIGN time - how do I get my hands on a corresponding VBControlExtender object for it. The only examples I've seen thus far involve the creation of objects using Form.Controls.Add - ie dynamic - which isn't what I'm trying to do...
My thanks in anticipation of anyone who feels like providing a burst of inspiration...
Martin