Firing events doesn't work
-
Hello All! I am newbie in ATL/COM programming, so I have tried to firing events based on this article http://www.codeproject.com/atl/SimpleATLCom.asp for VC 2005 final. I put the following code to the .h file
[ dispinterface, nonextensible, hidden, uuid("DEEA616A-2B80-4965-9A31-2F67B704EB70"), helpstring("_ISimpleObjEvents Interface") ] __interface _ISimpleObjEvents { [id(1), helpstring("method TotalMarks")] HRESULT TotalMarks([in] SHORT TotalMark); }; ... // CSimpleObj [ ... event_source(com), ... ] class ATL_NO_VTABLE CSimpleObj : public ISimpleObj { ... __event __interface _ISimpleObjEvents; ... }
And trying to rise event like this:__raise TotalMarks(TotalMark);
In my basic client I am trying to catch event like this:Private Sub Obj_TotalMarks(ByVal TotalMarks As Integer) 'Display the MessageBox displaying Total Marks MsgBox("total marks " & TotalMarks) End Sub
Help me please, where I am wrong?:sigh: -
Hello All! I am newbie in ATL/COM programming, so I have tried to firing events based on this article http://www.codeproject.com/atl/SimpleATLCom.asp for VC 2005 final. I put the following code to the .h file
[ dispinterface, nonextensible, hidden, uuid("DEEA616A-2B80-4965-9A31-2F67B704EB70"), helpstring("_ISimpleObjEvents Interface") ] __interface _ISimpleObjEvents { [id(1), helpstring("method TotalMarks")] HRESULT TotalMarks([in] SHORT TotalMark); }; ... // CSimpleObj [ ... event_source(com), ... ] class ATL_NO_VTABLE CSimpleObj : public ISimpleObj { ... __event __interface _ISimpleObjEvents; ... }
And trying to rise event like this:__raise TotalMarks(TotalMark);
In my basic client I am trying to catch event like this:Private Sub Obj_TotalMarks(ByVal TotalMarks As Integer) 'Display the MessageBox displaying Total Marks MsgBox("total marks " & TotalMarks) End Sub
Help me please, where I am wrong?:sigh: -
guess - are you missing WithEvents keyword when declaring your object in basic? For example - http://blogs.msdn.com/rssteam/archive/2006/06/08/Events-in-VB.NET.aspx[^]
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine