在新线程中创建对话框
假设我使用 CreateThread 创建一个线程,并且我想要在该线程中使用模式或非模式对话框。我是否需要像我这里一样使用单独的消息循环,
while(GetMessage(&msg, 0, 0, 0)) // Get any window messages
{
TranslateMessage(&msg); // Translate the message
DispatchMessage(&msg); // Dispatch the message
}
但是对于模式对话框,您不使用它,那么为什么当我创建对话框时它不能工作?
Suppose if i create a thread using CreateThread
, and I want a modal or modeless dialog in that thread. Do i need to use a seperate message loop for that like I have here,
while(GetMessage(&msg, 0, 0, 0)) // Get any window messages
{
TranslateMessage(&msg); // Translate the message
DispatchMessage(&msg); // Dispatch the message
}
But for modal dialog, you don't use that, so why shouldn't it work when i create a dialog?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用模式对话框时,它会创建自己的消息队列,这就是它的工作原理。如果您想使用无模式对话框,那么您必须自己创建一个消息队列。
来自
DialogBox
的文档:When you use a modal dialog, it creates its own message queue, that's why it works. If you want to use modeless dialogs then you will have to create a message queue yourself.
From the documentation for
DialogBox
: