PRB: Event Does Not Fire in the IDE When Raised from Inside a Compiled Modal FormID: Q237286
|
When using compiled components with events, and the event is triggered from a modal form inside the component, the event is not received by the client application when it is run from the Visual Basic Design Environment (IDE). This problem does not occur when both components have been compiled.
Display the form that triggers the event non-modally to avoid the problem when testing the application in the IDE.
This behavior is by design.
Option Explicit
Public Event DoSomething()
Public Sub FireEvent()
RaiseEvent DoSomething
End Sub
Public Sub ShowForm(ByVal ShowType As Long)
Form1.SetEventObject Me
If ShowType = vbModeless Then
Form1.Caption = "Non-Modal"
Form1.Show
Else
Form1.Caption = "Modal"
Form1.Show vbModal
End If
End Sub
Option Explicit
Dim EventObject As Class1
Public Sub SetEventObject(objNew As Class1)
Set EventObject = objNew
End Sub
Private Sub Command1_Click()
EventObject.FireEvent
End Sub
Private Sub Form_Load()
Command1.Caption = "Fire Event"
End Sub
Option Explicit
Dim WithEvents MyObj As MyEventsDll.Class1
Private Sub Command1_Click()
MyObj.ShowForm vbModal ' Show Form Modal
End Sub
Private Sub Command2_Click()
MyObj.ShowForm vbModeless ' Show Form Non-Modal
End Sub
Private Sub Form_Load()
Set MyObj = New MyEventsDll.Class1
Command1.Caption = "Show Form Modal"
Command2.Caption = "Show Form Non-Modal"
End Sub
Private Sub MyObj_DoSomething()
MsgBox "Received event from DLL"
End Sub
Additional query words:
Keywords : kbVBp kbVBp500 kbVBp600 kbIDEProject kbGrpVB kbDSupport
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: August 12, 1999