更改窗口的消息循环线程 [英] Changing a Window's message loop thread

查看:119
本文介绍了更改窗口的消息循环线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我试图在自己的线程中放置一个窗口的消息循环,我想知道为什么它从来没有收到任何消息,但我已经知道,Windows发布消息到创建窗口的线程。如何在一个线程中创建一个窗口,并使另一个线程接收该窗口的消息?我已经看到了PostThreadMessage函数,但我相信它也需要创建窗口的线程来侦听消息,这正是我试图避免的,所以这个函数不是我需要的。

Recently I tried putting a window's message loop in its own thread, and I wondered why it never received any messages, but I have learned that Windows posts messages to the thread that created the window. How do you create a window in one thread and cause another thread to receive that window's messages? I have seen the PostThreadMessage function but I believe that it also requires for the thread that created the window to listen for messages, which is exactly the thing I'm trying to avoid, so that function is not what I need.

这似乎是一个常见的问题,我花了相当多的时间Googling的答案,但我找不到一个。

This seems like it would be a common question and I have spent quite a bit of time Googling for an answer, but I can't find one.

推荐答案


如何在一个
线程中创建一个窗口,并引起另一个线程

How do you create a window in one thread and cause another thread to receive that window's messages?

简单的回答...你不知道。在要处理其消息的线程上创建窗口。如果这不可能,那么你需要重新考虑你的方法。

Simple answer ... you don't. Create the window on the thread you want to process its messages. If this is not possible then you need to re-think your approach.

这篇关于更改窗口的消息循环线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆