我从CWindowImpl继承了一个类,作为一个文本框。但是无法输入中文,就是直接用输入中文,比如输入一个'吃饭'(我用的微软拼音),结果他显示成'm'了,大部分中文都是什么都没有显示,但是如果复制粘贴中文是可以的,请问各位大侠,这是咋回事儿呢?要崩溃了,5555....

解决方案 »

  1.   

    估计是文本框的窗口类名被改变的结果,尽量不要用DECLARE_WND_SUPERCLASS宏
      

  2.   

    确实用了DECLARE_WND_SUPERCLASS这个宏,那怎么办呀?我现在比较菜,不太懂,5555....
      

  3.   

    实现IInputObjectSite这个接口,来控制输入
      

  4.   


    <H3>IInputObject Implementation </H3>
    <P>To get tabbing and input control to work correctly for any deskband is quite 
    simple. You need but to implement IInputObject. The host will query our deskband 
    to see if this interface is implemented and if it is will call the methods to 
    see if we require input focus and let us also process messages from the user 
    through the host. To do this, open the stockbar.h header file. To the stockbar 
    class declaration add the line below in bold, <PRE lang=c++>class ATL_NO_VTABLE CStockBar : 
       public CComObjectRootEx<CComSingleThreadModel>,
       public CComCoClass<CStockBar, &CLSID_StockBar>,
       public IDeskBand,
       public IObjectWithSite,
    <B>   public IInputObject,</B> 
       public IDispatchImpl<IStockBar, &IID_IStockBar, &LIBID_MOTLEYFOOLLib>
    {
    </PRE>Next scroll down to the COM Map and add an entry for IInputObject as shown 
    below in bold, <PRE lang=c++>BEGIN_COM_MAP(CStockBar)
       COM_INTERFACE_ENTRY(IStockBar)
    <B>   COM_INTERFACE_ENTRY(IInputObject)</B>
       COM_INTERFACE_ENTRY(IOleWindow)
       COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
       COM_INTERFACE_ENTRY(IObjectWithSite)
       COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
       COM_INTERFACE_ENTRY(IDispatch)
    END_COM_MAP()
    </PRE>Next add the following section of function declarations to your header 
    file, I placed mine before the IStockBar section. <PRE lang=c++>// IInputObject
    public:
       STDMETHOD(HasFocusIO)(void);
       STDMETHOD(TranslateAcceleratorIO)(LPMSG lpMsg);
       STDMETHOD(UIActivateIO)(BOOL fActivate, LPMSG lpMsg);
    </PRE>All that remains is to implement these three functions. Add the function 
    implementations below to the end of the stockbar.cpp source file. <PRE lang=c++>STDMETHODIMP CStockBar::HasFocusIO(void)
    {
       // if any of the windows in our toolbar have focus then return S_OK else S_FALSE.
       if (m_ReflectWnd.GetToolBar().m_hWnd == ::GetFocus())
          return S_OK;
       if (m_ReflectWnd.GetToolBar().GetEditBox().m_hWnd == ::GetFocus())
         return S_OK;
       return S_FALSE;
    }
    STDMETHODIMP CStockBar::TranslateAcceleratorIO(LPMSG lpMsg)
    {
       // the only window that needs to translate messages is our edit box so forward them.
       return m_ReflectWnd.GetToolBar().GetEditBox().TranslateAcceleratorIO(lpMsg);
    }
    STDMETHODIMP CStockBar::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
    {
       // if our deskband is being activated then set focus to the edit box.
       if(fActivate)
       {
          m_ReflectWnd.GetToolBar().GetEditBox().SetFocus();
       }
       return S_OK;
    }http://www.codeproject.com/atl/ietoolbartutorial.asp
      

  5.   

    可能你自己translate了中文输入,应该过滤一下,没有必要自己处理的交给系统处理好了