Someone has to say, play a showdialog is not finished?! Or MessageBox.Show ("saaaaa"), you can achieve your goal.
But you have to see the following situation, you will not say so.
I created an Excel in C #, and whenever I edit a value, I use C # code to determine if the values are valid and remind them when they are invalid. I use MessageBox.Show ("aaaaaaa");
But it doesn't have to be in the front, because it's C # code, so when Excel is at the front, that message box doesn't show up in the craniofacial.
You can resolve this problem by using the following methods:
MessageBox.Show ("The information to be played. "," Information ", MessageBoxButtons.OK, Messageboxicon.information,messageboxdefaultbutton.button1, ESSAGEBOXOPTIONS.DEFAULTDESKTOPONLY);
Oh, although still the MessageBox.Show, but a lot of people do not know AH. Everyone can try.
Source: http://www.cnblogs.com/pnljs/archive/2012/09/19/2694182.html=============================================== ========================================================= Use the above code, you can implement pop-up window at the top, but the combination of the first paragraph of code, can not close properly, directly error. The description calls the static extern bool EndDialog (IntPtr hdlg, out IntPtr nresult), and the method does not close the window properly, so let's find another API function that can close the window. Find the following code on the Internet:
Public Const intWm_close =0x10; [System.Runtime.InteropServices.DllImport ("user32.dll", EntryPoint ="SendMessageA")] Public Static extern intSendMessage (INTPTR hwnd,intWmsg,intWParam,intLParam);
Private voidButton1_Click (Objectsender, System.EventArgs e) {INTPTR Hwnd_win; Hwnd_win= FindWindow (NULL,"the name of the form to find"); SendMessage (Hwnd_win, Wm_close,0,0); }
Find window functions:
//Find Form[DllImport ("User32.dll", EntryPoint ="FindWindow")] Private Static extern intFindWindow (stringLpclassname,stringlpwindowname); Static voidMain () {//@Form1 get the form based on the text value of the form intWindow_handler = FindWindow (NULL,@"Form1"); }
Source: http://bbs.csdn.net/topics/340065537/====================================================================== ================= through the above steps, we can now properly implement the function we mentioned at the beginning of the article.
C # automatic pop-up window and timed auto-off