I am dynamically creating ComponentWorks objects in an MFC DLL. I found that I had to use a wrapper class derived from CWnd called CGraphBase. This class allows a window containing the CNiGraph (and another child window derived from CWnd) to be placed on a window that the DLL displays. The problem comes when I call the destructor. I get an Access Violation. The call stack looks like this:
68677561()
CWDISPLAYEDITOR! NI::CNiControl::WndProc(struct HWND__ *,unsigned int,unsigned int,long) + 105 bytes
USER32! 77e148dc()
USER32! 77e163fb()
USER32! 77e1643d()
NTDLL! 77f9f04b()
COleDispatchImpl::Release(COleDispatchImpl * const 0x055f84e0) line 1117
COleDispatchDriver::ReleaseDispatch() line 155
COleDispatchDriver::~COleDi
spatchDriver() line 85 + 15 bytes
COleControlSite::~COleControlSite() line 112 + 33 bytes
COleControlSite::`scalar deleting destructor'(unsigned int 1) + 15 bytes
COleControlSite::DestroyControl() line 291 + 31 bytes
CWnd::DestroyWindow() line 971 + 17 bytes
CWnd::~CWnd() line 760
CWDISPLAYEDITOR! NI::CNiControl::~CNiControl(void) + 31 bytes
CWDISPLAYEDITOR! NI::CNiGraph::~CNiGraph(void) + 74 bytes
CGraphBase::~CGraphBase() line 28 + 101 bytes
(CWDISPLAYEDITOR is the name of the DLL.)
It looks like the WndProc for the CNiCOntrol is being called after the control is destroyed. (I am calling this DLL from a LAbVIEW app.)
Can anyone give me any clues on how to fix this?
Thanks in advance.
Wayne