描述:
在Activez控件中WM_CHAR消息怎么不响应啊!各位高手有什么意见!
解决方案1:
在你的CActivexCtrl中,重载PreTranslateMessage处理WM_CHAR消息,就像fool_leave() 所说的;
WM_CHAR应该可以相应的;
楼主想截获什么类型的输入?
一般的都可以响应的呀,不过Syskey不可以
如下操作
改动三个方法
int CActivexCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
OnActivateInPlace (TRUE, NULL); // == UI-Activate the control
if(!m_pPanesOwner->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this, 12345)){
return -1;
}
return 0;
}
int CActivexCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
if (!m_bUIActive)
OnActivateInPlace (TRUE, NULL); // == UI-Activate the control
return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
BOOL CActivexCtrl::PreTranslateMessage(MSG* pMsg)
{
switch (pMsg->message)
{
case WM_KEYDOWN:
case WM_KEYUP:
switch (pMsg->wParam)
{
case VK_UP:
case VK_DOWN:
case VK_LEFT:
case VK_RIGHT:
case VK_HOME:
case VK_END:
case VK_TAB:
::SendMessage(pMsg->hwnd,pMsg->message, pMsg->wParam, pMsg->lParam);
return TRUE;
}
break;
}
return COleControl::PreTranslateMessage(pMsg);
}