本文是关于TranslateMessage官方文档的相关翻译,拿走不谢。

TranslateMessage函数将虚拟键消息转换成字符消息。该字符消息又被发送给对应线程(调用TranslateMessage的线程)的消息队列,当线程再次调用GetMessage函数或PeekMessage函数获取消息的时候被读取。

函数原型:

BOOL TranslateMessage(         

const MSG *lpMsg

);

参数说明:

lpMsg:指向由GetMessage或PeekMessage从调用线程消息队列获取的MSG信息结构。

返回值:

如果消息被转换(相应的字符消息被发送到调用线程的消息队列),返回值将为非零。

如果消息是 WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, 或 WM_SYSKEYUP,返回非零值,转换情况将被忽略。

如果消息没有转换(即,相应的字符消息没被发送到调用线程的消息队列中),返回值将是零。

注意事项:

TranslateMessage函数不修改由参数lpMsg指向的消息结构。

消息WM_KEYDOWN和WM_KEYUP组合产生一个WM_CHAR或WM_DEADCHAR消息。消息WM_SYSKEYDOWN和WM_SYSKEYUP组合产生一个WM_SYSCHAR或 WM_SYSDEADCHAR 消息。

TtanslateMessage函数仅为那些由键盘驱动器映射为ASCII字符的键产生WM_CHAR消息。

如果应用程序由于其它用途而需要处理虚拟键消息,则不应调用TranslateMessage函数。例如,当应用程序的TranslateAccelerator函数返回一个非零值时,它就不应该调用TranslateMessage函数。注意,应用程序负责检索和调度输入消息到该对话框,大多数程序使用主循环来完成这一工作。然而,要让用户可以通过键盘来进行控制操作,那么该程序必须调用IsDialogMessage函数。

//原文如下:

The TranslateMessage functiontranslates virtual-key messages into character messages. The character messagesare posted to the calling thread's message queue, to be read the next time thethread calls the GetMessage or PeekMessage function.

Syntax

BOOL TranslateMessage(

const MSG *lpMsg

);

Parameters

lpMsg

[in] Pointer to an MSGstructure that contains message information retrieved from the calling thread'smessage queue by using theGetMessage or PeekMessage function.

Return Value

If the message istranslated (that is, a character message is posted to the thread's messagequeue), the return value is nonzero.

If the message isWM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the return value isnonzero, regardless of the translation.

If the message is nottranslated (that is, a character message is not posted to the thread's messagequeue), the return value is zero.

Remarks

The TranslateMessage functiondoes not modify the message pointed to by thelpMsg parameter.

WM_KEYDOWN and WM_KEYUPcombinations produce a WM_CHAR or WM_DEADCHAR message.WM_SYSKEYDOWN andWM_SYSKEYUP combinations produce a WM_SYSCHAR or WM_SYSDEADCHAR message.

TranslateMessage producesWM_CHARmessages only for keys that are mapped to ASCII characters by the keyboarddriver.

If applications processvirtual-key messages for some other purpose, they should not callTranslateMessage. For instance,an application should not callTranslateMessageif the TranslateAccelerator function returns a nonzero value. Note that theapplication is responsible for retrieving and dispatching input messages to thedialog box. Most applications use the main message loop for this. However, topermit the user to move to and to select controls by using the keyboard, theapplication must call IsDialogMessage. For more information, see Dialog BoxKeyboard Interface.

Windows 95/98/Me: TranslateMessage is supportedby the Microsoft Layer for Unicode (MSLU). To use this, you must add certainfiles to your application, as outlined in Microsoft Layer for Unicode onWindows 95/98/Me Systems.

TranslateMessage函数相关推荐

  1. 消息循环中的TranslateMessage函数和DispatchMessage函数

    TranslateMessage函数 函数功能描述:将虚拟键消息转换为字符消息.字符消息被送到调用线程的消息队列中,在下一次线程调用函数GetMessage或PeekMessage时被读出. . 函数 ...

  2. (13)TranslateMessage函数

    TranslateMessage 是用来把虚拟键消息转换为字符消息.由于 Windows 对所有键盘编码都是采用虚拟键的定义,这样当按键按下时,并不得字符消息,需要键盘映射转换为字符的消息. Tran ...

  3. TranslateMessage函数 (转)

    TranslateMessage是用来把虚拟键消息转换为字符消息.由于Windows对所有键盘编码都是采用虚拟键的定义,这样当按键按下时,并不得字符消息,需要键盘映射转换为字符的消息. Transla ...

  4. 消息循环中的TranslateMessage函数和DispatchMessage函数,特别注意WM_TIMER消息

    TranslateMessage函数 函数功能描述:将虚拟键消息转换为字符消息.字符消息被送到调用线程的消息队列中,在下一次线程调用函数GetMessage或PeekMessage时被读出. .函数原 ...

  5. Windows API一日一练 13 TranslateMessage函数

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! Tran ...

  6. Windows API一日一练(13)TranslateMessage函数

    TranslateMessage是用来把虚拟键消息转换为字符消息.由于Windows对所有键盘编码都是采用虚拟键的定义,这样当按键按下时,并不得字符消息,需要键盘映射转换为字符的消息. Transla ...

  7. duilib中TranslateMessage函数和DispatchMessage函数

    TranslateMessage函数 函数功能描述:将虚拟键消息转换为字符消息.字符消息被送到调用线程的消息队列中,在下一次线程调用函数GetMessage或PeekMessage时被读出. .函数原 ...

  8. C++ -- TranslateMessage函数

    TranslateMessage是用来把虚拟键消息转换为字符消息.由于Windows对所有键盘编码都是采用虚拟键的定义,这样当按键按下时,并不得字符消息,需要键盘映射转换为字符的消息. Transla ...

  9. 十五: TranslateMessage(msg) 函数 和DispatchMessage(msg)函数

    TranslateMessage函数将虚拟键消息转换为字符消息.字符消息被寄送到调用线程的消息队列里,当下一次线程调用函数GetMessage或PeekMessage时被读出. TranslateMe ...

最新文章

  1. 解决ubuntu中遇到“E:Unable to locate package rar” 的问题
  2. linux——编写Shell脚本常用命令:diff、patch、cut、sort、uniq、、||、test、tr
  3. 【项目管理】质量管理
  4. ibatis和myibatis
  5. Windows Server 2003 DNS服务安装篇
  6. robot motion planning介绍
  7. 首批骁龙875旗舰!小米11屏幕依然是挖孔
  8. NGUI_2.6.3_系列教程二
  9. 将MFC Grid Control封装为DLL的做法及其在DLL中的使用方法
  10. 阿里云服务器如何进行网站域名解析?
  11. CF584D 【Dima and Lisa】题解
  12. Hamcrest 断言
  13. C语言链表翻转的三种实现方式(栈、头插法、递归法)
  14. 英语听力训练常采用的方法
  15. 重磅发布:史上首份揭秘微信公众号用户行为习惯研究报告
  16. 赛尔无人机 | 航测新标杆 Phantom 4 RTK
  17. 数据恢复软件有哪些好用又免费的?强推这6款神器
  18. 我的第一篇博客!!!万里长征第一步!!!
  19. C++_enhance-Record11—异常的层次结构(继承在异常中的应用)
  20. 建立一个Point类,包含数据成员x,y,实现需要的成员函数,并设计main函数完成测试

热门文章

  1. 企业邮箱搬家及扩容流程
  2. 2021年远程办公未来发展趋势如何?
  3. Remmina 启动 VBoxManage
  4. Python-3反爬虫原理与绕过实战
  5. oracle中删除表的步骤,Oracle中删除表,删除数据以及恢复数据
  6. 华为linux系统能不能一键碰传,怎么实现华为手机电脑间的一碰互 华为手机电脑一碰互传 - 云骑士一键重装系统...
  7. 从mq服务器中获取消息命令,MQ服务消息队列介绍
  8. spring starter原理和实例
  9. 投票服务器维护时间,梦幻西游《维护解读》108:“春心萌动”大赛投票开启,门派调整部分服务器开测...
  10. Android 学习总结--六大常用布局