user942451
user942451

Reputation: 1795

Creating a dialog in new thread

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?

Upvotes: 0

Views: 1552

Answers (1)

K-ballo
K-ballo

Reputation: 81349

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.

Upvotes: 2

Related Questions