我在VC6中开发了我的ActiveX COM组件。我在它上面创建了firebreath插件,以便能够从不同的浏览器调用COM API。我在ActiveX组件中有一个API弹出CDialog UI,在Google Chrome浏览器dlg.DoModal()函数失败。问题只出在Chrome上,它只是在此次通话时崩溃,在其他浏览器中它完全正常工作
在Windows 7上,与谷歌浏览器一起使用的问题还有Windows XP。
请就此问题向我提供一些反馈。
我在这里附上一些代码片段,以便了解我正在尝试做什么
Firebreath插件代码(插件名称为FBTest):
bool FBTest::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *piw)
{
// The window is attached; act appropriately
try {
/* Now that we have the plugin window, create the ActiveX container
window as a child of the plugin, then create the ActiveX control
as a child of the container.
*/
FB::PluginWindowWin* pwnd = piw->get_as<FB::PluginWindowWin>();
if(pwnd != NULL)
{
HWND hWnd = pwnd->getHWND();
if(hWnd)
{
// Create the ActiveX control container
RECT rc;
::GetClientRect(hWnd, &rc);
m_fbTestWin.Create(hWnd, &rc, 0, WS_VISIBLE|WS_CHILD);
CComPtr<IUnknown> spControlTest;
//ETESTPROGID is prog id of activex component
HRESULT hrTest = m_fbTestWin.CreateControlEx(ETESTPROGID, NULL, NULL, &spControlTest, GUID_NULL, NULL);
if(SUCCEEDED(hrTest) && (spControlTest != NULL))
{
spControlTest.QueryInterface(&m_eTestAxCtl);
g_eTestAxCtl = m_eTestAxCtl;
if (m_eTestAxCtl)
{
//TODO: should we throw a FB exception here?
}
}
}
}
} catch(...) {
//TODO: should we throw a FB exception here?
}
return false;
}
void FBTest::TestFunc()
{
//hThread = (HANDLE)_beginthreadex(NULL, 0,&FBTest::Start, (void*)&m_eTestAxCtl, 0, &ThreadId);
if(m_eTestAxCtl)
{
try {
long nCode = -1;
//This is call to API of Activex component which will popup the dialog
HRESULT hr = m_eTestAxCtl->TestFunc();
//return nCode;
}
catch(...) {
}
}
}
Activex组件代码:
STDMETHODIMP CTest::TestFunc()
{
//CTestDlg is ATL Dialog Object
CTestDlg TestDlg;
//At this call Google chrome is crashing
if(!TestDlg.DoModal())
return S_FALSE;
return S_OK;
}
我从一个HTML页面调用插件的TestFunc()API,它在IE和firefox浏览器中显示了dailog但是Chrome崩溃了..
请帮忙。
答案 0 :(得分:0)
由于你没有提供关于何时或如何调用它的信息,因此很难确定,但我的猜测是你在主线程上调用了DoModal。这将导致主线程阻塞。
您必须 从不 阻止插件中的主要线程。
尝试在另一个主题上调用它。