Home > Net >  Messagebox hidden
Messagebox hidden

Time:11-14

Wrote a PC, open a thread in the form1, in another FUN. Cs call a function, the function to deal with an Excel file, then Save and the pop-up dialog prompt file Save Success, MessageBox. Show (" the Save Data Success!" );
But this dialog doesn't appear in the top, want oneself to the task bar to find out some "OK" to eliminate,
Great god please help take a look at how to make this dialog box appears before the main form?

CodePudding user response:

 yourForm. The BeginInvoke (delegate (Action) 
{
. Save
}


If you want to block the thread, changed the BeginInvoke to Invoke,

CodePudding user response:

reference 1st floor interacting in a professional developer response:
 yourForm. The BeginInvoke (delegate (Action) 
{
. Save
}


If you want to block the thread, changed the BeginInvoke to Invoke,
I'm sorry, this code is in form1. In cs, I am ready to func. Call in the cs, don't seem to call form1. The BeginInvoke

CodePudding user response:

MessageBox is a block type routines, will block the other in the process of operation, must be, after the completion of its acceptance process can continue other operation, therefore, if only hint a message, it is recommended to use other ways (for example, use the information bar or dialog boxes).

CodePudding user response:

refer to the second floor zengtiantian112 response:
Quote: refer to 1st floor interacting in a professional developer response:
 yourForm. The BeginInvoke (delegate (Action) 
{
. Save
}


If you want to block the thread, changed the BeginInvoke to Invoke,
I'm sorry, this code is in form1. In cs, I am ready to func. Call in the cs, don't seem to call form1. The BeginInvoke

It is an event

CodePudding user response:

You need to modify the FUN. The function in the cs, namely the modified MessageBox invoked the specified Handle (Handle), the problem is difficult to deal with from outside, in general the FUNC. Cs design, an underlying function should not be a pop-up MessageBox dialog box or interface forms, such as can multithreaded operations function, in particular, if you must pop up, then this function should Handle with a parameter, said the caller's Handle,

CodePudding user response:

Custom pop-up layer, timing closure?

CodePudding user response:

Specify MessageBox the owner of the top-level Windows can be realized, MessageBox itself is to support the background play and the foreground window
Or call SetForeground directly

CodePudding user response:

refer to the second floor zengtiantian112 response:
Quote: refer to 1st floor interacting in a professional developer response:
 yourForm. The BeginInvoke (delegate (Action) 
{
. Save
}


If you want to block the thread, changed the BeginInvoke to Invoke,
I'm sorry, this code is in form1. In cs, I am ready to func. Call in the cs, don't seem to call form1. The BeginInvoke


Form1 can serve as a reference form instance parameter form into your treatment, can also define a global (static) reference,

In fact I am not sure MessageBox will be "hidden", you just have a try, in a static variable reference your Application's main window, or even from Application. OpenForms take first, here only to try and see if I can make the UI main thread is blocked,

CodePudding user response:

For example,
 namespace WindowsFormsApp1 
{
Static class Program
{
///& lt; Summary>
///the application's main entry point,
///& lt;/summary>
[STAThread]
The static void Main ()
{
Application. EnableVisualStyles ();
Application. SetCompatibleTextRenderingDefault (false);
MyForm1=new _click ();
Application. The Run (MyForm1);
}

The static public Form1 MyForm1;
}
}

This can be in any local reference form directly with the Class,
  •  Tags:  
  • C#
  • Related