windows中进队消息和不进队消息的区别?

quwei197874 2011-08-25 11:45:51
如题,请各位解释一下
...全文
185 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
moheng1 2011-08-25
  • 打赏
  • 举报
回复
4楼说的对。。。
gold_water 2011-08-25
  • 打赏
  • 举报
回复
消息分为队列消息(进入线程的消息队列)和非队列消息(不进入线程的消息队列)。对于队列消息,最常见的是鼠标和键盘触发的消息,例如WM_MOUSERMOVE,WM_CHAR等消息;还有例如:WM_PAINT、WM_TIMER和WM_QUIT。当鼠标、键盘事件被触发后,相应的鼠标或键盘驱动程序就会把这些事件转换成相应的消息,然后输送到系统消息队列,由Windows系统负责把消息加入到相应线程的消息队列中,于是就有了消息循环(从消息队列中读取并派送消息)。还有一种是非队列消息,他绕过系统队列和消息队列,直接将消息发送到窗口过程。例如,当用户激活一个窗口系统发送WM_ACTIVATE, WM_SETFOCUS, and WM_SETCURSOR。创建窗口时发送WM_CREATE消息。在后面你将看到,MS这么设计是很有道理的,以及他的整套实现机制
ndy_w 2011-08-25
  • 打赏
  • 举报
回复
Windows uses two methods to route messages to a window procedure: (1) posting messages to a first-in, first-out queue called a message queue, which is a system-defined memory object that temporarily stores messages; and (2) sending messages directly to a window procedure. Messages posted to a message queue are called queued messages. They are primarily the result of user input via the mouse or keyboard, such as WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_KEYDOWN, and WM_CHAR messages. Other queued messages include the timer, paint, and quit messages: WM_TIMER, WM_PAINT, and WM_QUIT. Most other messages are sent directly to a window procedure and are called, surprisingly enough, nonqueued messages.

Queued Messages
Windows NT maintains a single system-message queue and any number of thread-message queues, one for each thread. Whenever the user moves the mouse, clicks the mouse buttons, or types at the keyboard, the device driver for the mouse or keyboard converts the input into messages and places them in the system-message queue. Windows removes the messages, one at a time, from the system-message queue, examines them to determine the destination window, and then posts them to the message queue of the thread that created the destination window. A thread's message queue receives all mouse and keyboard messages for the windows created by the thread. The thread removes messages from its queue and directs Windows NT to send them to the appropriate window procedure for processing. The system posts a message to a thread's message queue by filling an MSG structure and then copying it to the message queue. Information in the MSG structure includes the handle of the window for which the message is intended, the message identifier, the two message parameters, the message time, and the mouse-cursor position. A thread can post a message to its own message queue or to the queue of another thread by using the PostMessage or PostThreadMessage function.

Nonqueued Messages
Nonqueued messages are sent immediately to the destination window procedure, bypassing the system-message queue and thread-message queue. Windows typically sends nonqueued messages to notify a window of events that affect it. For example, when the user activates a new application window, Windows sends the window a series of messages, including WM_ACTIVATE, WM_SETFOCUS, and WM_SETCURSOR. These messages notify the window that it has been activated, that keyboard input is being directed to the window, and that the mouse cursor has been moved within the borders of the window. Certain Windows function calls can prompt nonqueued messages. For example, Windows sends the WM_WINDOWPOSCHANGED message after an application uses the SetWindowPos function to move a window.

danxuezx 2011-08-25
  • 打赏
  • 举报
回复
clear251 2011-08-25
  • 打赏
  • 举报
回复
SendMessage:不进队,主要是向一个或多个窗口发送一条消息,一直等到消息被处理之后才会返回。
PostMessage:进队,把一条消息放置到创建hWnd窗口的线程的消息队列中,该函数不等消息被处理就马上将控制返回。
sichuanwww 2011-08-25
  • 打赏
  • 举报
回复
进队的,就是PostMessage,就是需要消息队列来处理,是异步,
不进队,就是SendMessage,就是直接要求窗口过程函数来处理,一般用于同步
oyljerry 2011-08-25
  • 打赏
  • 举报
回复
进队的,就是PostMessage,就是需要消息队列来处理,是异步,
不进队,就是SendMessage,就是直接要求窗口过程函数来处理,一般用于同步
danxuezx 2011-08-25
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 visualeleven 的回复:]
PostMessage/SendMessage
[/Quote]
支持部长,一语中的,言简意赅!
jixiang1983 2011-08-25
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 gibsonboy 的回复:]
深度解析VC中的消息
[/Quote]
++
canmeng 2011-08-25
  • 打赏
  • 举报
回复
这个问题比较有深度。好好学习。
gibsonboy 2011-08-25
  • 打赏
  • 举报
回复
Eleven 2011-08-25
  • 打赏
  • 举报
回复
PostMessage/SendMessage
本工具多次测试均未出现问题,可以使用,如果发现自己无法使用,请先看下面介绍与说明 谢谢!! 感谢驴友yxrsys,在verycd发布资源 非安装软件,直接双击运行,傻瓜式修复,可运行于32位和64位系统和WINPE系统 程序根据当前系统non-Unicode设置自动显示/英界面 "自动修复"自动判断和系统启动有关的条件并自动修复程序支持的盘符上的NT系统启动,无需用户手工干预 "高级修复"只供特殊需要的朋友,参看下面应用实例的高级修复部分 PE自动判断PE环境,单硬盘可以直接"自动修复",如多硬盘在PE修复时推荐使用"高级"修复选择你作为系统引导的盘符 适用范围: -------- 1.启动菜单/启动文件丢失修复: 适用所有NT5.x(2000/XP/2003)和NT6.x(Vista/2008/Win7/2008r2) 2.修复其他因BCD相关引起的故障 a. Win7/2008r2 BCD 的修复计算机(Windows Recovery Environment)菜单丢失 b. Win7/2008r2 BCD 引起的3D启动画面丢失(变成VISTA滚动条启动画面) c. BCD 引起的启动菜单选择界面乱码现象 3.系统BCD非法的强制修复 - 现象:Vista/2008/Win7/2008r2 a. 运行msconfig后"启动"或"引导"栏空白 b. 管理员身份运行命令提示符后运行bcdedit等和BCD相关的操作提示出错 c. 系统属性的"启动和故障恢复"窗口无法配置"默认操作系统"和"等待时间" d. 其他软件无法添加/删除/修改基于 BCD 管理的新启动菜单 注: 3的这种情况是否要强制修复自行决定。 额外功能: 为VISTA/2008添加修复计算机(Windows Recovery Environment)菜单 使用方法:在系统盘符新建recovery文件夹,再把光盘或安装程序的boot\boot.sdi和sources\boot.wim复制至 recovery文件夹,再运行本程序,即可自动添加。 修复效果: 存在原BCD或Boot.ini时程序将予备份,备份文件名/路径在修复完成后给出提示 NT5.x菜单在boot.ini以"Microsoft Windows Server 2003 x86"形式存在 NT6.x菜单在BCD以"Windows Server ® 2008 Standard x86"形式存在 NT6.x的修复过程提示成功即时写入生效,NT5.x的修复在最后完成后再一并写入生效 NT5.x支持最多同接8个硬盘时的修复,但如果不同接口硬盘混用且三个或以上硬盘就未必能准确判断硬盘号,三硬盘以上 并混用的情况就算微软自己的控制台都未必能准确判断 NT6.x理论无限制硬盘数,也不限制混用 根据当前系统non-Unicode设置决定修复后的启动菜单/英优先级 NT5.x+NT6.x的多系统 - 当存在多个NT5.x时,修复后BCD显示的NT5.x相应菜单为“Earlier Version of Windows”, 当只有一个NT5.x系统,修复后BCD显示的NT5.x相应菜单则为类如"Microsoft Windows Server 2003 x86"格式 不修复NT5.x的Boot.ini和NT6.x的BCD的多余的启动菜单 因为精简版的精简程度无从判断,所以不保证能修复精简版系统启动故障 自BCDautofix发布以来极少回答一些朋友在使用上的疑问,这里和NTBOOTautofix一并释疑 一、BUG报告:readme写的邮箱我极少打开,所以未必能及时回信。 二、请不要拿本工具和EasyBCD或VistaBoorPro等工具作比较: 那类工具重在管理 - 如改启动菜单名,添加/删除菜单等,要用在修复功能上需要使用者自己了解故障原因和解决流程后 才能手工修复,多数情况下其手工也无法完美修复。 而本工具重在修复,修复功能大多是那类工具无法实现的,当然本工具也不能实现那类工具的管理操作。 三、程序用批处理编写:请看不起批处理的免下载使用而避免下载后浪费诸多表情 四、如不能修复请自己先了解一下是否程序适用范围内:例如有些硬件原因引起的3D启动画面不存在,象这类的非BCD引起的类似故障是此工具无法处理的 五、手工处理教程为什么不写:其实以前曾经写过很多,但并不多人看,有时一个“活动分区”的识别就要大花唇舌说明,一句bcdedit /set {ntldr} description "Microsoft Windows XP"或bootsect /nt60 sys可以解决的手工处理方式不少人都

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧