开发者

Creating a dialog in new thread

开发者 https://www.devze.com 2023-04-07 03:19 出处:网络
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,

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 th开发者_StackOverflow社区e message
}

But for modal dialog, you don't use that, so why shouldn't it work when i create a dialog?


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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消