用create方法在控件中创建一个窗体,然后用showwindow的方式显示,此时在窗体上按tab, enter , 上下左右按键,无效。改怎么处理?
环境
VC6 MFC 创建 OCX 
客户端用 VB6调用

解决方案 »

  1.   

    响应WM_GETDLGCODE, 返回XX_WANTAALLKEEY.(在外面上的网,查不到资料,记不到返回值了)
      

  2.   

    你可以在PreTranslateMessage中截获这些消息通过PostMessage发给控件窗口就好了
      

  3.   

    1.in your init function.call this
    MSG msg;
    while (::IsWindowVisible(g_hOEMainWnd))
    {
    if(GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg);

    // Send all keyboard messages to the window of your
    // application.  hwndApp is the window handle of
    // your application.
    //

    // if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST && msg.message == WM_KEYDOWN)
    // ::SendMessage(this->m_hWnd,msg.message, msg.wParam, msg.lParam);

    DispatchMessage(&msg);
    }
    }
    2.in your dialog function deal OnKeydown function
    LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam,
    BOOL& bHandled)
    {
    // m_spWebBrowser is a data member of type IWebBrowser2.
    // Using CComQIPtr in this way queries m_spWebBrowser
    // for the IOleInPlaceActiveObject interface which is
    // then stored in the pIOIPAO variable.
    //
    CComQIPtr<IOleInPlaceActiveObject,
    &IID_IOleInPlaceActiveObject> pIOIPAO(m_spWebBrowser);

    HRESULT hr = S_FALSE;

    if (pIOIPAO)
    {
    MSG msg;
    msg.message = uMsg;
    msg.wParam = wParam;
    msg.lParam = lParam;

    hr = pIOIPAO->TranslateAccelerator(&msg);
    }

    return hr;
    }
    for more details ,msdn have an article talking about this
      

  4.   

    添加:WM_GETDLGCODE消息
    LRESULT OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {

    return DLGC_WANTARROWS;//手动改写
    }