Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event Handle (Urgent) ...

Status
Not open for further replies.

daniloa

Programmer
Nov 23, 2001
27
0
0
BR
Hi everyone,

I'm with problems to receive an OCX event, the issue is this:

I have an OCX (mfc control) that have an Event declared on "public:" part of an class named CAlcUraCtrl like this:

//{{AFX_EVENT(CAlcUraCtrl)
void FireOnHangUp(long eCanal)
{FireEvent(eventidOnHangUp, EVENT_PARAM(VTS_I4), eCanal);}
//}}AFX_EVENT

and on my control.cpp source your declaration is:

BEGIN_EVENT_MAP(CAlcUraCtrl, COleControl)
//{{AFX_EVENT_MAP(CAlcUraCtrl)
EVENT_CUSTOM("OnHangUp", FireOnHangUp, VTS_I4)
//}}AFX_EVENT_MAP
END_EVENT_MAP()

and in .odl file is:

dispinterface _DAlcUraEvents
{
properties:
// Event interface has no properties
methods:
// NOTE - ClassWizard will maintain event information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_EVENT(CAlcUraCtrl)
[id(1)] void OnHangUp(long eCanal);
//}}AFX_ODL_EVENT
};

When I compile and build is OK, I have no error or warnings. On VB when I load this OCX I found this events with no problems too, but they never are handled.

On my OCX source I do this to send the Event:

CAlcUraCtrl* FLH;
//
FLH = new CAlcUraCtrl;
FLH->FireOnHangUp(chdev);
//
delete FLH;

And I never receive the event on VB:

Private Sub CAlcUraCtrl1_OnHangUp(eCanal as Long)

Please tell I'm doing something wrong??? Because I'm a Beginner on VC++ and I'm to learning working ...

Very Thanks,

Danilo ...
 
I think i know what the problem is the event isn';t coming through to vb beacuse you are defining a new instance of your control (ObjNew) and firing the event of the new control just defined, not the actual control itself if that makes any sense?

I think what you should do is in the control souce where you want the event to fire (say onClick) is just to add the line

FireOnHangUp(chdev)
or
this->FireOnHangUp(chdev)


As you can see you are firing the event of the actual control itself using the "this".

Hope this helps [ponytails]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top