Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Firing events doesn't work

Firing events doesn't work

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Romiks
    wrote on last edited by
    #1

    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:

    L 1 Reply Last reply
    0
    • R Romiks

      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:

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      R 1 Reply Last reply
      0
      • L Lost User

        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

        R Offline
        R Offline
        Romiks
        wrote on last edited by
        #3

        Thanks a lot, the problem was resolved by adding the "Handles Obj.TotalMarks" at the end of Obj_TotalMarks subroutine definition: Private Sub Obj_TotalMarks(ByVal TotalMarks As Integer) Handles Obj.TotalMarks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups