For reference, this is the code for testing a callback.
.NET interface that defines the callback class.
.NET class for testing the callback. This uses the same frmTest form as before.Code:Imports System.Runtime.InteropServices <ComVisible(True), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> Public Interface IControlCallback Sub TestCallback() End Interface
In VB6 I created a callback class for handling the code that should run when clicking the .NET form button.Code:Imports System.Runtime.InteropServices <ComVisible(True), ClassInterface(ClassInterfaceType.AutoDual)> Public Class TestCallback Private WithEvents _Form As New frmTest ReadOnly Property Callback As IFromCallback Public Sub SetCallback(Callback As IFromCallback) _Callback = Callback End Sub Public Sub ShowNonModal() _Form.Show() End Sub Public Sub ShowModal() _Form.ShowDialog() End Sub Private Sub _Form_Testing() Handles _Form.Testing If Callback IsNot Nothing Then Callback.TestCallback() End If End Sub End Class
Now in VB6 create the code for running the .NET class with a reference to the VB6 callback class.Code:Option Explicit Implements IFormCallback Private Sub IFormCallback_TestCallback() Debug.Print "Callback hit!" MsgBox "Testing msgbox through callback" 'Now open a modal form through the callback. frmTest.Show 1 End Sub
And to my surprise, this now works!Code:Private Sub Command1_Click() Dim Callback As New FormCallback Dim TestNetCallback As New TestCallback TestNetCallback.SetCallback Callback TestNetCallback.ShowModal End SubI will test this more thoroughly to see what I missed last time.
![]()




I will test this more thoroughly to see what I missed last time.
Reply With Quote
