我用atl做的IE toolbar,然后想在用户输入时,捕捉按下enter的事件,我用了TranslateAcceleratorIO(LPMSG lpMsg),然后如果事件是wm_keydown而且是回车,就xxx,否则交还回去:
TranslateMessage(lpMsg);
DispatchMessage(lpMsg);
结果我发现,如果输入中文的话,输入完了就变了,比如输入'吃饭',变成'm',大部分情况下是空的,但是如果复制过去中文没有问题,英文及字符输入也没有问题,请问大家知不知道这个怎么回事儿呢?
多谢了~_~
TranslateMessage(lpMsg);
DispatchMessage(lpMsg);
结果我发现,如果输入中文的话,输入完了就变了,比如输入'吃饭',变成'm',大部分情况下是空的,但是如果复制过去中文没有问题,英文及字符输入也没有问题,请问大家知不知道这个怎么回事儿呢?
多谢了~_~
解决方案 »
- 我是新手,我只想问一个小问题
- 关于SOCKET的疑问
- ObjectARX 2006 + VC2002 无法在AutoCAD 2008上运行
- 如何改变树控件中某一个结点的字体和颜色
- vc2003上的程序在2005上怎么build
- zhoujianhei 来接分(二)!
- IE7中文版和IE7英文版添加信任站点后, 注册表的存储方式为什么不一样呢?有什么方法判断IE7是中文版还是英文版呢?
- mfc查看本机各种网络服务的状态?
- inline void TESTHR (HRESULT _hr) ( if FAILED(_hr) throw(_hr);)这两句到底什么意思?顺便问一句TESTHR到底是什么东东?干什么用的?
- COM编程问题
- [请教]在IE toolbar里文本框输入中文的问题
- 我的DrawText不好用,帮我看看为什么,应该怎么改
<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
TranslateMessage(lpMsg);
DispatchMessage(lpMsg);而是直接返回S_FALSE,让系统来处理,应该就可以了