2010-04-20 日志
在MFC对话框中嵌入web网页时,网页初始化中添加事件无效
javascript
document.body.onkeydown = function ()
{
//onkeydown="keydownbody()" 不能激发
alert(event.keyCode);
if(event.keyCode == 27)//VK_ESCAPE //String.fromcharcode('A');
{
if (external != null && external.map_is_full_screen() == 1)
{
external.map_full_screen();
}
}
}
原来主线程截断了消息
cpp
BOOL CXXXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if ((pMsg->message == WM_KEYDOWN)&&(pMsg->wParam == VK_ESCAPE))
{
m_pXXXManagerDlg->AreaMessage(pMsg);
//if(m_hMapGWnd)::SendMessage(m_hMapGWnd,pMsg->message,pMsg->wParam,pMsg->lParam);
//使用上面的语句又会被CXXXXDlg::PreTranslateMessage(MSG* pMsg)拦截,必须使用接口方法或者自定义消息。
return TRUE;
}
//...
return CDialog::PreTranslateMessage(pMsg);
}