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!

Call events in ActiveX Control

Status
Not open for further replies.

VBGuyUsingVC

Programmer
Jan 10, 2002
24
US
Hi,

I'm not certain what needs to be done here. I want my activeX control to fire an event. Here's a sample:

//my app will call this function first (DoWatch) and then
//wait on events to fire
BOOL CAxCtrl::DoWatch(LPCTSTR strToWatch, long dwChangesToWatch, BOOL bWatchSub)
{
// TODO: Add your dispatch handler code here
dc.StartWatch((CString)strDirToWatch, (DWORD)dwChangesToWatch, &dch,bWatchSub);
return TRUE;
}

//a thread created by dc.StartWatch calls this
//function when certain condition arise:
void mWatchHandler::On_DataIn(const CString &strName)
{
CAxCtrl *RaiseEvent = new CAxCtrl;
RaiseEvent->TriggerEvent_DataIn(strName);
delete RaiseEvent;
}

CAxCtrl::TriggerEvent_DataIn(LPCTSTR strName)
{
FireDataIn(strName); //function is called but event is not triggered is app (????)
}
 
If I'm reading your problem correctly, I've got a suggestion:

Set a breakpoint on the FireDataIn() line and step into the function to make sure it's not just returning without doing what you expect it to.

Better yet, have FireDataIn() return success or failure and add error handling.
 
Thanks for the response,

The FireDataIn() is one of the MFC activeX events that I set up using ClassWizzard. I thought I all I had to do is call it and the event would be raised in my app. My breakpoint is never reached in the app the control is on, even though it is in fact being called from within the control.

I guess what I'm trying to do is call an event in one class from another class. I'm not having success. If I try to call it directly I get some compiler error about calling non-static functions.

Thanks for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top