我从CWindowImpl继承了一个类,作为一个文本框。但是无法输入中文,就是直接用输入中文,比如输入一个'吃饭'(我用的微软拼音),结果他显示成'm'了,大部分中文都是什么都没有显示,但是如果复制粘贴中文是可以的,请问各位大侠,这是咋回事儿呢?要崩溃了,5555....
解决方案 »
- debug assertion failed
- Invalid procedure call or argument求高手解决
- 在VC中一个工作空间下的两个工程文件如何相互调用?
- 关于录音的问题?
- 关于STATIC中TEXT的问题
- 一个令我很郁闷的问题,
- void CString::Format(LPCSTR pasFormat, ...)的实现
- 请问如何将access数据库转为mysql数据库?急!在线等待!
- 一个SDK的简单问题,却让我相当困惑!
- 不好意思了,问问大家一个硬件的问题
- 如何创建一个线程队列,并把删除文件线程插入队列,在线程中删除文件
- [~_~]关于Translate和中文输入问题求助
<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