• IE中ocx控件的无模式对话框不接收方向键等键盘消息的问题的解决办法


    在ocx控件中如果含有无模式对话框,那么当ocx在ie中显示时,往往接收不到
    诸如tab,方向键和退格键。所有这些消息都被IE容器给截取了,对于这个问题,ms给出了解决方法:
    首先:
      int CMyActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
       {
          if (COleControl::OnCreate(lpCreateStruct) == -1)
             return -1;
          OnActivateInPlace (TRUE, NULL); // == UI-Activate the control
          return 0;
       }
     激活控件,以便能接收键盘消息。
    其次 跟踪转发消息
      // trap keys and forward on to the control
       BOOL CMyActiveXCtrl::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);
                      // Windowless controls won't be able to call SendMessage.
                      // Instead, just respond to the message here.
                      return TRUE;
                }
                break;
          }
          return COleControl::PreTranslateMessage(pMsg);
       }
    注意用send而不要用post
  • 相关阅读:
    Java之五种遍历Map集合的方式
    CUDA功能和通用功能
    编写CUDA内核
    LLD-LLVM链接器
    Pass Infrastructure基础架构(下)
    Pass Infrastructure基础架构(上)
    算子规范化
    多级中间表示概述MLIR
    “ compiler-rt”运行时runtime库
    LLDB调试器
  • 原文地址:https://www.cnblogs.com/lidabo/p/2981862.html
Copyright © 2020-2023  润新知