Modeless dialog in IE through ATL/COM dll

Visual Studio303
Hello,



I am creating a ATL/COM component(dll) which adds the context menu in

IE. After clicking on that menu it calls annother ATL/COM componet

which shows the Modeless HTML dialog box.

The problem is everything opens fine but suppose when i right click

conext menu and that opens the other HTML Modeless dialog. as it is

Modeless I can also click on IE's any web page. When i click on any

link it open another instance of IE. And when I closes that 2nd

intance of IE i got exception of memory in my dll workspace.



[Unhandled exception at 0x777849cc in iexplore.exe: 0xC0000005: Access

violation reading location 0xeee9bee8.]



In Debug mode it shows the pointer here in dbgheap.c file's



extern "C" void * __cdecl _heap_alloc_dbg(size_t nSize,

int nBlockUse,

const char * szFileName,

int nLine

)

{

................

}

__finally {

/* unlock the heap

*/

_munlock(_HEAP_LOCK); <---- Here it shows

the problem

}

return retval;

}



--------------------------------------------------------------------------------------------------

And in Release mode:

void __cdecl __addlocaleref( pthreadlocinfo ptloci)

{

....



InterlockedIncrement(&(ptloci->lc_time_curr->refcount)); <----

Here it shows the problem

}



-----------------------------------------------------------------------------------------------------

This is My Code snippet of creating HTML modeless dialog



CMMBDHTMLDlg *dlg = new CMMBDHTMLDlg();



dlg->m_strType.Empty();

dlg->m_strType=L"2"; //img case

dlg->m_strSelItem=CString(strlink);

QueryInterface(IID_IMMBUICOMP,(void**) &dlg->pComp);

dlg->m_strUser=CString(p_bstrUserID);



dlg->Create(MAKEINTRESOURCE(IDD_MMBDHTMLDLG));

dlg->ShowWindow(SW_NORMAL);



I am deleting dlg here in CMMBDHTMLDlg class's



void CMMBDHTMLDlg::PostNcDestroy()

{



CDHtmlDialog::PostNcDestroy();



delete this;

}





Please tell me the issue.....



Klic


-