为什么我的WM_UNICHAR处理器从未调用? [英] Why is my WM_UNICHAR handler never called?

查看:363
本文介绍了为什么我的WM_UNICHAR处理器从未调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ATL控件,我想要支持Unicode。我为WM_UNICHAR添加了一个消息处理程序:

  MESSAGE_HANDLER(WM_UNICHAR,OnUniChar)

但是,由于某些原因,OnUniChar处理程序从未被调用。



该处理程序应该首先用UNICODE_NOCHAR调用,如果要接收UTF-32字符,处理程序应该返回TRUE。但是,正如我所说,处理程序从未被调用。



有什么特殊的东西需要被激活吗?



如果你的代码(或ATL),你应该生成一个WM_UNICHAR消息代码)最终调用CreateWindowW,那么你的窗口已经知道Unicode,WM_CHAR消息将是UTF-16格式。



文档在何时,一个WM_UNICHAR消息被生成,但从我可以收集在Google网上论坛和互联网上的非常有限的戳,它看起来像是由第三方应用程序发送,而不是由Windows本身,除非窗口是一个ANSI窗口(CreateWindowA和所有)。你试过手动发送一个WM_UNICHAR消息到你的窗口看看会发生什么?如果你得到的消息,那么你的消息分派代码没有什么问题,只有没有发生,会导致WM_UNICHAR。你也可以检查Spy ++,看看你是否得到那个消息,虽然我怀疑它只是没有发送。


I have an ATL control that I want to be Unicode-aware. I added a message handler for WM_UNICHAR:

MESSAGE_HANDLER( WM_UNICHAR, OnUniChar )

But, for some reason, the OnUniChar handler is never called.

According to the documentation, the handler should first be called with "UNICODE_NOCHAR", on which the handler should return TRUE if you want to receive UTF-32 characters. But, as I said, the handler is never called.

Is there anything special that needs to be done to activate this?

解决方案

What are you doing that you think should generate a WM_UNICHAR message?

If your code (or the ATL code) ultimately calls CreateWindowW, then your window is already Unicode aware, and WM_CHAR messages will be UTF-16 format.

The documentation is far from clear on when, exactly, a WM_UNICHAR message gets generated, but from what I can gather in very limited poking around on Google Groups and on the Internet it looks like it gets sent by 3rd party apps and not by Windows itself, unless the Window is an ANSI window (CreateWindowA and all that). Have you tried manually sending a WM_UNICHAR message to your window to see what happens? If you get the message then there's nothing wrong with your message dispatch code and there's just nothing happening that would cause WM_UNICHAR. You can also check with Spy++ and see whether you're getting that message, though I suspect it's just not being sent.

这篇关于为什么我的WM_UNICHAR处理器从未调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆