gpt4 book ai didi

c++ - 在新线程中创建对话框

转载 作者:行者123 更新时间:2023-11-28 03:46:23 25 4
gpt4 key购买 nike

假设我使用 CreateThread 创建一个线程,并且我想在该线程中有一个模态或非模态对话框。我是否需要像这里那样使用单独的消息循环,

while(GetMessage(&msg, 0, 0, 0)) // Get any window messages
{
TranslateMessage(&msg); // Translate the message
DispatchMessage(&msg); // Dispatch the message
}

但是对于模态对话框,您不使用它,所以为什么在我创建对话框时它不起作用?

最佳答案

当您使用模态对话框时,它会创建自己的消息队列,这就是它起作用的原因。如果你想使用无模式对话框,那么你必须自己创建一个消息队列。

来自 DialogBox 的文档:

The DialogBox macro uses the CreateWindowEx function to create the dialog box. (snip) and starts its own message loop to retrieve and dispatch messages for the dialog box.

关于c++ - 在新线程中创建对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7509593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com