Original Post
Ok, i'm trying to use delegates to allow someone using the engine i'm developing to specify handlers for gui elements (Yes yes, i know, i'm the only one gonna use it, but it's still good practice) Anyway, i'm getting the most bizzare error messages, lemme elaborate with what i've tried so far:
Public Delegate Sub ReceiveClick(ByVal x As Integer, ByVal y As Integer, ByVal Buttons() As Byte)
Public Interface infComplex
Property Top() As Integer
Property Left() As Integer
ReadOnly Property Surf() As Surface
ReadOnly Property Rect() As Rectangle
Property ZValue() As Integer
Property Visible() As Boolean
Sub ReceiveClicks(ByVal X As Integer, ByVal y As Integer, ByVal buttons() As Byte)
Sub Render()
Sub move(ByVal x As Integer, ByVal y As Integer)
Sub Handler(ByVal Handler As ReceiveClick)
End Interface
then, later on, in my clswindows structure...
Sub handler(ByVal Handler As ReceiveClick) Implements infComplex.Handler
dHandler = Handler
End Sub
Ok, and i'm getting this as my error:
C:\Documents and Settings\Darva\My Documents\Visual Studio Projects\AsylumEngine\Asylum.vb(530): 'AsylumEngine.clsWindow' must implement 'Sub Handler(Handler As ReceiveClick)' for interface 'AsylumEngine.infComplex'.
C:\Documents and Settings\Darva\My Documents\Visual Studio Projects\AsylumEngine\Asylum.vb(639): 'handler' cannot implement 'Handler' because there is no matching sub on interface 'infComplex'.
I've also tried it without the public keyword in front of "Delgate sub ReceiveClick", and the error message i get is:
C:\Documents and Settings\Darva\My Documents\Visual Studio Projects\AsylumEngine\Asylum.vb(352): 'Handler' cannot expose a Friend type outside of the Public interface 'infComplex'.
The only solution i can come up with is stepping out of using interfaces, moving the definition of "Receiveclick" into the base class, and inheriting from the base class. If that's the only way it'll work, i'll do it, but if someone can show me how to make it work the way I'm going now, i'd be happy, because i don't wanna re-write all the menial stuff i'll have to re-write in switching.
Thanks
Darva
[edited by - ZenDarva on June 2, 2004 12:31:49 AM]