Hi,
I want to raise an event in ActiveX DLL and want to trap that event in a exe. This exe is calling that ActiveX DLL.
I am successful able to raise an event in ActiveX DLL but its not firing that event in Exe.
Kindly tell me why it is not working, or am I doing something wrong?
Any help will be highly appericiated.
Here is the code for my Project:
ActiveX DLL Name: CalledDLL(classes: CNotify,MyDLL. Form: FrmFromDLL.frm(form Has button: Lauch EXE's TestForm)
Exe Name : CallingEXE(FrmMain.frm,Tes
tForm)
***EXE***
Form frmMain
--------------------------
----------
--------
Private WithEvents objNotify As CalledDLL.CNotify
Private Sub cmdDLL_Click()
Dim objMyDLL As New CalledDLL.MyDLL
objMyDLL.ShowDLLForm
End Sub
Private Sub Form_Load()
Set objNotify = New CalledDLL.CNotify
End Sub
Public Sub objNotify_Notify(sMsg As String)
MsgBox sMsg
End Sub
***ActiveX DLL***
cNotify
--------------------------
----------
--------
Option Explicit
Public Event Notify(ByRef Source As String)
Public Sub CallNotify(Source As String)
RaiseEvent Notify(Source)
End Sub
MyDLL
--------------------------
----------
--------
Public Event MyEvent()
Private m_Client As New CNotify
Public Sub ShowDLLForm()
frmFormDLL.Show
End Sub
Public Sub TestCallback()
' Something that requires an "event"
If Not (m_Client Is Nothing) Then
m_Client.CallNotify ("fee")
Else
RaiseEvent MyEvent
End If
End Sub
frmFormDLL
--------------------------
----------
--------
Public Event Notify(ByRef Source As String)
Private Sub cmdTest_Click()
CallNotify ("Test")
End Sub
Private Sub Form_Load()
'Set objNotify = New CNotify
End Sub
Public Sub CallNotify(Source As String)
RaiseEvent Notify(Source)
End Sub
Start Free Trial