// dialog_messagebox.cpp
#include "../common.h"
// prototypes of local functions
static void StartThread_ThisDialog (void *thread_parms);
void DialogBox_Message (messagebox_t *messagebox_parms)
{
// helper function to fire up the modeless dialog box
is_dialogbox_displayed = true;
_beginthread (StartThread_ThisDialog, 0, (void *) messagebox_parms); // fire up the thread
return; // return as soon as the thread is fired up
}
void DialogBox_Message_Validated (void)
{
// callback function called by the main game thread when the dialog box is validated
// remember this callback is no longer to be called
is_dialogbox_message_validated = false;
return; // finished
}
static void StartThread_ThisDialog (void *thread_parms)
{
// this function runs in a separate thread, for that's the only way (seemingly)
// to implement a non-modal message box using the Common Controls library.
messagebox_t *mb;
mb = (messagebox_t *) thread_parms; // quick access to message box structure
// display the message box and wait for it to return
MessageBox (IsWindow (mb->hWndParent) ? mb->hWndParent : (IsWindow (hMainWnd) ? hMainWnd : NULL), mb->text, mb->title, mb->flags);
is_dialogbox_message_validated = true;
is_dialogbox_displayed = false;
the_board.reevaluate = true; // refresh the GUI buttons if needed
return; // _endthread() implied
}