VC写的OCX,在IE上使用,控制里有一个FormView的派声类,里面有三个EDIT控制,我想让它按TAB键时焦点跳到下一个,但是焦点却跳到IE的地址栏去了,如何支持TAB键?

解决方案 »

  1.   

    pretranslatemessageCommand what is yours
    Conquer what is not
      

  2.   

    Knowledge Base  
     Q168777
    PRB: MFC ActiveX Control in IE Doesn't Detect Keystrokes
     // 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:
                      SendMessage (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);
       }
      int CMyActiveXCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT
       message)
       {
          if (!m_bUIActive)
              OnActivateInPlace (TRUE, NULL); // == UI-Activate the control
          return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
       }
       int CMyActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
       {
          if (COleControl::OnCreate(lpCreateStruct) == -1)
             return -1;
          OnActivateInPlace (TRUE, NULL); // == UI-Activate the control
          return 0;
       }