Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this correct? Understanding Implements.

Status
Not open for further replies.

Sorwen

Technical User
Nov 30, 2002
1,641
US
To help save time on my wrapper and to make sure it was correct I found that AxImp.exe will create a wrapper for a dll. At the same time you can have it output the code it uses as C#. I converted it using an online converter. For the moment I'll assume that all of that was done correctly. The problem is that none of the events were working. Here is the example of the AfterConnect code it created.

Code:
Namespace AxObjectXAS400Display
    Public Class AxObjectXAS400Display
        Inherits System.Windows.Forms.AxHost

        Private eventMulticaster As AxObjectXAS400DisplayEventMulticaster

        Public Event AfterConnect As IObjectXAS400DisplayEvents_AfterConnectEventHandler

        Friend Sub RaiseOnAfterConnect(ByVal sender As Object, ByVal e As IObjectXAS400DisplayEvents_AfterConnectEvent)
            RaiseEvent AfterConnect(sender, e)
        End Sub
    End Class

    Public Class AxObjectXAS400DisplayEventMulticaster
        Public Delegate Sub IObjectXAS400DisplayEvents_AfterConnectEventHandler(ByVal sender As Object, ByVal e As IObjectXAS400DisplayEvents_AfterConnectEvent)
        Public Class IObjectXAS400DisplayEvents_AfterConnectEvent
            Public success As Integer

            Public Sub New(ByVal success As Integer)
                Me.success = success
            End Sub
        End Class

        Public Overridable Sub AfterConnect(ByVal success As Integer)
            Dim afterconnectEvent As New IObjectXAS400DisplayEvents_AfterConnectEvent(success)
            Me.parent.RaiseOnAfterConnect(Me.parent, afterconnectEvent)
        End Sub

        Public Sub AfterConnect1(ByVal Success As Integer) Implements ObjectXAS400Display.IObjectXAS400DisplayEvents.AfterConnect
            [red]AfterConnect(Success)[/red] [green]'I added as it didn't do anything until I did.  I don't know if this is correct or not though.[/green]
        End Sub
    End Class
End Namespace
The Sub AfterConnect1 that Implements AfterConnect gets hit, but unless in that even I use the sub AfterConnect the Project that uses this will never fire off the AfterConnect event. Once that line is in then everything works fine. Is this the correct use of Implements with Events or has something got messed up in all of the translation?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
I should have said AxImp.exe creates a wrapper for a ActiveX control(dll/ocx).

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
I'll have to move forward this way as it seems to be working correctly at least.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top