hexagon logo

Can anybody give a help on how to handle application evens in C++?

Hi all,

I'm a pc-dmis developer using visual C++. When I use pc-dmis in 4.2 or lower version, I use ActiveX object to handle the application events.
But when I upgrade pc-dmis to 2010 and higher, this way is no longer work properly. When I handled a events such as "end-execution", the EXE tell me it is stop working ( not in 4.2 and lower version ).
So I want to find another way. I import pcdlrn.tlb into VC, but I don't know how to connect the IApplicationEvents object to pc-dmis. When the part-program executing ends, nothing happen to the EXE.
If somebody can tell me how to do this, I will be very appreciate.
Thanks!

The code generated by VC when impor pcdlrn.tlb is as following:
/////////////////////////////////////////////////////////////////////////////
// IApplicationEvents wrapper class

class IApplicationEvents : public COleDispatchDriver
{
public:
IApplicationEvents() {} // Calls COleDispatchDriver default constructor
IApplicationEvents(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
IApplicationEvents(const IApplicationEvents& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}

// Attributes
public:

// Operations
public:
void OnObjectAboutToExecute(LPDISPATCH PartProg, LPDISPATCH Cmmd);
void OnObjectExecuted(LPDISPATCH PartProg, LPDISPATCH Cmmd);
void OnStartExecution(LPDISPATCH PartProg);
void OnEndExecution(LPDISPATCH PartProg, long TerminationType);
void OnAddObject(LPDISPATCH PartProg, LPDISPATCH Command);
void OnOpenPartProgram(LPDISPATCH PartProg);
void OnClosePartProgram(LPDISPATCH PartProg);
void OnSavePartProgram(LPDISPATCH PartProg);
void OnUpdateStatusMessage(LPCTSTR Msg);
void OnOpenRemotePanelDialog(LPDISPATCH PartProg, long DialogId, long hWnd, LPCTSTR Message, long BtnId1, long BtnId2, long BtnId3, long BtnId4, long DefaultBtn);
void OnConnectSlave(LPDISPATCH PartProg);
void OnDisconnectSlave(LPDISPATCH PartProg);
void OnObjectAboutToExecute2(LPDISPATCH PartProg, LPDISPATCH Cmmd, long Arm);
void OnObjectExecuted2(LPDISPATCH PartProg, LPDISPATCH Cmmd, long Arm);
void OnOpenRemotePanelDialog2(LPDISPATCH PartProg, long DialogId, long hWnd, LPCTSTR Message, long BtnId1, long BtnId2, long BtnId3, long BtnId4, long BtnId5, long DefaultBtn);
void OnCloseRemotePanelDialog(LPDISPATCH PartProg, long DialogId, long hClosedWnd, LPCTSTR Message, long PushedBtnID);
void OnPCDMessageBoxOpen(LPDISPATCH PCDMessageBox);
void OnPCDMessageBoxClose(LPDISPATCH PCDMessageBox, long PushedBtnID);
void OnOpenExecutionDialog(LPDISPATCH ExecutionWindow);
void OnCloseExecutionDialog(LPDISPATCH ExecutionWindow);
void OnCommentInputDialogOpen(LPDISPATCH CommentInputDialog);
void OnCommentInputDialogClose(LPDISPATCH CommentInputDialog, long PushedBtnID);
void OnExecutionDialogButton(LPDISPATCH ExecutionWindow, long PushedBtnID);
};


void IApplicationEvents::OnEndExecution(LPDISPATCH PartProg, long TerminationType)
{
static BYTE parms[] =
VTS_DISPATCH VTS_I4;
InvokeHelper(0x4, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
PartProg, TerminationType);
}