thank you j-b
Ok,I will describe the problem with more specifiction.
when I set more than two vlc in my MFC application,In the release vlc fuction,in the second "for cycle",at vlc
->destroywindow(); the app will crash.and jump this window: Monitors.exe at 0x7c92eb74 exception: 0xC0000008: An invalid handle was specified.
and the code will jump into occsite.cpp ,at m_pObject->Release();:
Code: Select all
COleControlSite::COleControlSite(COleControlContainer* pCtrlCont) :
m_pCtrlCont(pCtrlCont),
m_pWndCtrl(NULL),
m_pDC(NULL),
m_nID((UINT)-1),
m_pObject(NULL),
m_pInPlaceObject(NULL),
m_pActiveObject(NULL),
m_pWindowlessObject(NULL),
m_dwEventSink(0),
m_dwPropNotifySink(0),
m_dwMiscStatus(0),
m_dwNotifyDBEvents(0),
m_pDataSourceControl(NULL),
m_pDSCSite(NULL),
m_defdispid(0),
m_dwType(0),
m_pBindings(NULL),
m_bIgnoreNotify(FALSE),
m_bIsDirty(FALSE),
m_bIsWindowless(FALSE)
{
memset(&m_varResult, 0, sizeof(VARIANT));
m_varResult.vt = VT_EMPTY;
}
COleControlSite::~COleControlSite()
{
if (m_pCtrlCont && m_pCtrlCont->m_pSiteCapture == this)
{
m_pCtrlCont->m_pSiteCapture = NULL;
}
delete m_pDataSourceControl;
DetachWindow();
DisconnectSink(m_iidEvents, m_dwEventSink);
DisconnectSink(IID_IPropertyNotifySink, m_dwPropNotifySink);
DisconnectSink(IID_INotifyDBEvents, m_dwNotifyDBEvents);
if (m_pWindowlessObject != NULL)
{
m_pWindowlessObject->Release();
m_pWindowlessObject = NULL;
}
if (m_pInPlaceObject != NULL)
{
m_pInPlaceObject->InPlaceDeactivate();
m_pInPlaceObject->Release();
m_pInPlaceObject = NULL;
}
if (m_pActiveObject != NULL)
{
m_pActiveObject->Release();
m_pActiveObject = NULL;
}
if (m_pObject != NULL)
{
m_pObject->SetClientSite(NULL);
m_pObject->Close(OLECLOSE_NOSAVE);
m_pObject->Release();
m_pObject = NULL;
}
::VariantClear(&m_varResult);
BindProperty(DISPID_UNKNOWN, NULL); // gets rid of complex bindings
if (m_defdispid != 0 && m_pDSCSite != NULL &&
m_pDSCSite->m_pDataSourceControl != NULL)
{
// get rid of simple bindings
m_pDSCSite->m_pDataSourceControl->BindProp(this, FALSE);
}
if (m_pCtrlCont && m_bIsWindowless)
{
m_pCtrlCont->m_nWindowlessControls--;
ASSERT(m_pCtrlCont->m_nWindowlessControls >= 0);
}
}
Any question with the release fuction that I have writed?
thank you !
Best Regards,
maojz