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

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

问题描述

我有一个 ATL 控件,我希望它能够识别 Unicode.我为 WM_UNICHAR 添加了一个消息处理程序:

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 )

但是,出于某种原因,永远不会调用 OnUniChar 处理程序.

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

根据文档,应该首先使用UNICODE_NOCHAR"调用处理程序,如果您想接收 UTF-32 字符,处理程序应该返回 TRUE.但是,正如我所说,处理程序永远不会被调用.

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?

推荐答案

您认为应该在做什么时生成 WM_UNICHAR 消息?

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

如果您的代码(或 ATL 代码)最终调用了 CreateWindowW,那么您的窗口已经可以识别 Unicode,并且 WM_CHAR 消息将是 UTF-16 格式.

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.

文档远未明确说明何时生成 WM_UNICHAR 消息,但从我在 Google 网上论坛和互联网上非常有限的搜查中收集到的信息来看,它看起来像是由 3rd 方应用程序发送的,而不是由 Windows 本身,除非 Window 是一个 ANSI 窗口(CreateWindowA 和所有这些).您是否尝试过手动向窗口发送 WM_UNICHAR 消息以查看会发生什么?如果您收到消息,那么您的消息发送代码就没有问题,并且不会发生任何会导致 WM_UNICHAR 的事件.您还可以使用 Spy++ 查看是否收到该消息,但我怀疑它只是没有发送.

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天全站免登陆