Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
is there a way to turn off the MessageBox by clicking the mouse on any place on the screen and not just on the cross or button?

Thanks for the advice and tips.
David

What I have tried:

C#
  private Form Formular()
        {
            Form form1 = new Form();
            form1.Text = "Upozornění";
            return form1;
        }
 protected async override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                await QueuedTask.Run(() =>
                {
                    var form1 = Formular();
                    form1.Close();
...
 if (shape == null)
                    {
                        form1 = Formular();
                        form1.ShowDialog();
                        //MessageBox.Show("Nebyla zvolena anotace!");

                        return;
                    }
Posted
Updated 17-Jul-22 23:58pm
v2
Comments
Richard MacCutchan 18-Jul-22 5:56am    
No, because it is a Dialog window, which is designed to stop the main form from responding until it is dismissed.

No, Messagebox is not extendable - it isn't even a Control in C#, and has only static methods.

The simplest solution is to create your own: all you need is a form that isn't resizable, with a caption and a static Show or ShowDialog method to pass the string.
You can then handle the Click event yourself and close the form.
 
Share this answer
 
Comments
dejf111 18-Jul-22 5:50am    
I know what you mean, but somehow I can't put it together.
OriginalGriff 18-Jul-22 6:23am    
You know how to create a form, I assume?
And you know how to handle a Click event?

So what part is difficult for you?
dejf111 18-Jul-22 6:45am    
I know how to do that, but I have a problem that it should be in the same Click event. The point is that I click on the text that I want to move, but when I click outside the text, it should show me that no text was selected, but I also have a Doubleclick event that should turn off the created AddIn, but as soon as I click, the Form opens again which cannot be closed by Click.
As an alternative to the solution #1 by OriginalGriff - you can create messagebox which closes automatically. See: c# - Close a MessageBox after several seconds - Stack Overflow[^]
The simplest way is to use this: MessageBox with a timeout for .NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900