Is there any way to make the MessageBox behave as modeless?

  • Thread starter Thread starter krishna.simhadri
  • Start date Start date
K

krishna.simhadri

Hi,

I am developing an automation script(C#) and in that I am displaying a
MessageBox(using system.windows.forms) to alert the user.If the user
responds,then it is fine.But if the user doesn't respond by clicking
on the MessageBox buttons,the dialog is there forever stopping the
code below the MessageBox.show() from executing permanently.

If the message box is of modeless type I can wait for some time and if
the user doesn't respond, I can close the MessageBox and exit.

Is there any MessageBox that is of modeless type or any way to make
the MessageBox behave in modeless manner?

Any help would be appreciated.

Thanks in advance.
 
Is there any MessageBox that is of modeless type or any way to make
the MessageBox behave in modeless manner?

Nope. Windows Forms ultimately calls the Win32 MessageBox() API function,
which always displays the dialog modally. Your best bet is to create your
own form which mimics the MessageBox.
 
<[email protected]> wrote in message
news:6375c669-4b53-4edf-83b3-2972bb564757@r15g2000prh.googlegroups.com...

> Is there any MessageBox that is of modeless type or any way to make
> the MessageBox behave in modeless manner?


Nope. Windows Forms ultimately calls the Win32 MessageBox() API function,
which always displays the dialog modally. Your best bet is to create your
own form which mimics the MessageBox.

You can do that by starting another thread. Pass the message to the thread. In the thread call the MessageBox function. But you will have to coordinate the response back to the main code. Run your timing in the main code and if there is no response kill the thread.
 
Back
Top