本帖最后由 EDDGA 于 2012-01-27 19:15:33 编辑

解决方案 »

  1.   

    有个TThreadList可以使用一下,比较方便
      

  2.   

    1. The thread to which the message is posted must have created a message queue, or else the call to PostThreadMessage fails.
    所以不会建立消息队列。2. MSDN中对PostThreadMessage的参数idThread的注解中有:
    The system creates a thread's message queue when the thread makes its first call to one of the User or GDI functions. 而PeekMessage就是user32.dll的一个导出函数,所以会建立消息队列。3. SubThread结束的时候,不要释放这个SubThread.MainThreadHandle,因为它就相当于栈上的一个局部变量。4. 在PostThreadMessage的MSDN 帮助中没找到对于线程是否挂起的限制,所以会加入到队列。5. 是。
      

  3.   

    使用PostThreadMessage发送直到成功,线程消息队列一定会建立,而PeekMessage调用一次建立消息队列是不可靠的,做了大量自动化实验而非手动执行验证,The system creates a thread's message queue when the thread makes its first call to one of the User or GDI function太宽泛不靠谱。