Hello,

I have a MsgBox utility that basically creates a message box ontop of a windows form to ensure the message bis is the the topmost form. The code is:

//***********************************************************************//
//*******FUNCTION TO ENSURE DIALOG/MESSAGE BOXES ARE ALWAYS 'ON TOP'*****//
//***********************************************************************//

public static class MsgBox
{
static public DialogResult Show(string message, string title, MessageBoxButtons buttons, MessageBoxIcon icons)
{
// Create a host form that is a TopMost window which will be the parent of the MessageBox.
System.Windows.Forms.Form topmostForm = new System.Windows.Forms.Form();

topmostForm.Size = new System.Drawing.Size(40, 40);
topmostForm.StartPosition = FormStartPosition.Manual;
System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
topmostForm.Location = new System.Drawing.Point(rect.Bottom + 12, rect.Right + 12);
topmostForm.Show();

// Make this form the active form and make it TopMost
topmostForm.Focus();
topmostForm.BringToFront();
topmostForm.TopMost = true;

// Finally show the MessageBox with the form just created as its owner
Keyboard.Enabled = true;
Mouse.Enabled = true;
DialogResult result = MessageBox.Show(topmostForm, message, title, buttons, icons);
topmostForm.Dispose(); // clean it up all the way
return result;
}
}

-------------------------------------------------------------------------------------------------------------------------

The entire program is an automated test and purpose of the message box is to inform the user whether the test completed, failed execution, or was aborted by the user. It is called using the code below:

//****Display Error Dialog if an Error Occurs or Success Dialog if Test Completes Without Errors****//
if (error == -1)
{
CommonUtilLib.Util.MsgBox.Show("An Error Has Occurred, Test Aborted.","Test Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Report.Error("AN ERROR HAS BEEN REPORTED WHICH WILL NOT ALLOW RANOREX TO CONTINUE EXECUTION. PLEASE EXAMINE YOUR LOG REPORT FOR MORE INFORMATION");
}
else if (error == 0)
{
CommonUtilLib.Util.MsgBox.Show("Test Successfully Executed","Test Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
Report.Info("YOUR RANOREX TEST HAS EXECUTED SUCCESSFULLY. PLEASE EXAMINE YOUR LOG REPORT FOR MORE INFORMATION");
}
else if (error == 1)
{
CommonUtilLib.Util.MsgBox.Show("You Have Aborted the Test","Test Aborted", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Report.Warn("YOU HAVE ABORTED THE TEST. THE REPORT LOG HAS STOPPED LOGGING DATA");
}
-------------------------------------------------------------------------------------------------------------------------

what im really hoping to do is to display the message box when necessary, and if the user hasnt responded to it with 30 seconds then I want to set the result = "OK" and destroy the form

Can anyone offer any direction or examples on how to do this? Thanks