In order to try reproducing the crash in IE8 on my side, I write an example
of calling script from a MFC safe AcitveX control hosted in IE. The
complete example has been checked into my team's project:
All-In-One Code Framework
http://cfx.codeplex.com
See the changeset 22487 in
http://cfx.codeplex.com/SourceControl/ListDownloadableCommits.aspx.
The example works well in IE 8 on my side.
===================
To run the example:
Download the changeset 22487, and open CodeFx 2008 - COM.sln in an elevated
instance of Visual Studio. Build the examples HTMLEmbedActiveX and
MFCSafeActiveX, then run HTMLEmbedActiveX. Open the page
MFCSafeActiveX.html which loads the MFCSafeActiveX control. Enter
"HelloWorld" in the text box for "Call Script", and click the button "Call
Script". "HelloWorld" is the name of a javascript in the page. When
clicking "Call Script", the MFC ActiveX control reads the script name, and
invoke the script using COleDispatchDriver::InvokeHelper. IE will pop up an
alert dialog "HelloWorld" which tell you that the call succeeds.
===================
The major codes of the example:
Here is the code that calls the script from MFC ActiveX control:
void CMFCSafeActiveXCtrl::CallHtmlScript(LPTSTR pszScript)
{
HRESULT hr;
IOleClientSite *pOleClientSite = this->GetClientSite();
ASSERT(pOleClientSite);
IOleContainer *pOleContainer = NULL;
hr = pOleClientSite->GetContainer(&pOleContainer);
ASSERT(SUCCEEDED(hr) && pOleContainer);
IHTMLDocument *pHtmlDoc = NULL;
hr = pOleContainer->QueryInterface(IID_IHTMLDocument, (void**)&pHtmlDoc);
ASSERT(SUCCEEDED(hr) && pHtmlDoc);
// Get the script object (this returns the script object, NOT the script
// element(s) that the get_scripts method does).
IDispatch* pDispScript = NULL;
hr = pHtmlDoc->get_Script(&pDispScript);
ASSERT(SUCCEEDED(hr) && pDispScript);
COleDispatchDriver oddScript;
oddScript.AttachDispatch(pDispScript);
// Call the specified (strScript) script function.
OLECHAR* pScriptName = T2OLE(pszScript);
DISPID dispidScript;
hr = pDispScript->GetIDsOfNames(IID_NULL, &pScriptName, 1,
LOCALE_SYSTEM_DEFAULT, &dispidScript);
ASSERT(SUCCEEDED(hr));
oddScript.InvokeHelper(dispidScript, DISPATCH_METHOD, VT_EMPTY, NULL,
NULL);
// Cleanup
if (pDispScript)
pDispScript->Release();
if (pHtmlDoc)
pHtmlDoc->Release();
if (pOleContainer)
pOleContainer->Release();
if (pOleClientSite)
pOleClientSite->Release();
oddScript.DetachDispatch();
}
Although the target script does not return any value or take any parameters
in this demo, I have tested the condition of "return value" offline. The
test succeeds too.
My suggestion is that, you may consider running my sample code first. If it
succeeds, move your codes into the example piece by piece. After every
move, test the web page again to see whether IE crashes. When IE crashes,
it means that the piece of code that was just moved into the sample is the
culprit. Then we can further investigate the reason.
Regards,
Jialiang Ge (jia...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
By the way, may I know your feedback about "All-In-One Code Framework"?
Your comments are particularly precious for this newly started project.
Thanks
Jialiang Ge (jia...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================