Myforwik
Myforwik

Reputation: 3588

win32: change MessageBox text?

My program has multiple threads. I am using messagebox to display information to the user. Is there anyway (or an alternative to message box) that I can have another thread update/change the message-box display text while the message box is still on the screen and visible by the user?

Upvotes: 1

Views: 2324

Answers (3)

Remy Lebeau
Remy Lebeau

Reputation: 596332

Using thread-specific hooks via GetCurrentThreadId() and SetWindowsHookEx(), you can hook the messages that MessageBox() receives internally, as well as gain access to the dialog's main window handle, which then gains you access to all of the child controls of the dialog. You can then customize the dialog and its control as needed. This technique is commonly used for implementing self-closing dialogs (before MessageBoxTimeout() was introduced), customize the text of the buttons, etc.

Upvotes: 2

Waleed Eissa
Waleed Eissa

Reputation: 10513

I don't believe there's a direct way to do this, you probably could try to get the window handle but this is way too messy. Your best bet is to create your own dialog box so that you you have total control over it.

Upvotes: 0

Filip Frącz
Filip Frącz

Reputation: 5947

If you are using a standard Win32 message box I don't believe there is any way of changing the text once the box is already shown (you enter a modal message pump).

I would suggest you create your own window that listens to messages/updates from your other threads. That way you are in control.

Upvotes: 5

Related Questions