zoukankan      html  css  js  c++  java
  • PostMessage和SendMessage

     

    测试了一下。

    如果在同一个线程内,PostMessage发送消息时,消息要先放入线程的消息队列,然后通过消息循环Dispatch到目标窗口。SendMessage发送消息时,系统直接调用目标窗口的消息处理程序,并将结果返回。SendMessage在同一线程中发送消息并不入线程消息队列。

    如果在不同线程内。最好用PostThreadMessage代替PostMessage,他工作的很好。SendMessage发送消息到目标窗口所属的线程的消息队列,然后发送消息的线程等待(事实上,他应该还在做一些监测工作,比如监视QS_SENDMESSAGE标志),直到目标窗口处理完并且结果返回,发送消息的线程才继续运行。这是SendMessage的一般情况,事实上,处理过程要复杂的多。比如,当发送消息的线程监测到有别的窗口SendMessage一个消息到来时,他直接调用窗口处理过程,并将处理结果返回(这个过程不需要消息循环中GetMessage等的支持)。

    这是一套有点复杂的机制。呵呵~

    msdn:

    If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage, SendNotifyMessage, and SendMessageCallback), its message parameters can not include pointers. Otherwise, the operation will fail.

    如果发送的消息码在WM_USER之下(非自定义消息)且消息参数中带有指针,那么PostMessage,SendNotifyMessage,SendMessageCallback这些异步消息发送函数将会调用失败。

    Take Care.呵呵~

  • 相关阅读:
    MySQL数据库的基本操作命令
    autoCAD2014安装过程
    网站降权与恢复
    移动站的优化技巧
    Robots.txt详解
    友情链接交换技巧
    网站日志分析
    seo-网站内容的创建与优化
    网站外链的建设技巧
    网站内链优化
  • 原文地址:https://www.cnblogs.com/huqingyu/p/40956.html
Copyright © 2011-2022 走看看