在windows内部,有一个系统消息队列;每个线程可以有0~1个消息队列;每个应用程序可以有1~n个消息队列,取决与应用程序有几个线程及线程有没有消息队列:The system maintains a single system message queue and one thread-specific message queue for each GUI thread. To avoid the overhead of creating a message queue for non-GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the Win32 User or GDI functions.Whenever the user moves the mouse, clicks the mouse buttons, or types on the keyboard, the device driver for the mouse or keyboard converts the input into messages and places them in the system message queue. The system 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 the system to send them to the appropriate window procedure for processing. 

解决方案 »

  1.   

    有消息队列的叫界面线程,没有的叫工作者线程,其实线程初建的时候都没有消息队列,系统会不会给一个线程建消息队列取决于这个线程会不会调用user或GDI函数,一旦调用系统就会给它建立消息队列,一个线程消息队列内部是由数个队列及一些标志组成,它们是POST,SEND,INPUT,REPLY四个队列,唤醒与QUIT标志和局部焦点变量。窗口的消息队列其实就是创建这个窗口线程的消息队列中发给这个窗口的消息组成的,没有线程消息队列就没有窗口消息队列。
      

  2.   

    没记错的话,在WINDOWS 2000下多个线程可以共享一个消息队列。
      

  3.   

    xlfrd(大于弱智) 在《WINDOWS高级编程指南》看到的吧,呵呵,这本书不错,较基础底层的东西。------jeffrey richter
      

  4.   

    LZLZ(柳州浪子):呵呵,国内很少有讲WINDOWS底层一些的好书。
      

  5.   

    E() 说的对
    to:xlfrd(大于弱智) 你说的我不知道,能谈谈从哪来的吗?谢谢。
      

  6.   

    to:bighead 《WINDOWS高级编程指南》第章第二节第370页 :)