C # automatic pop-up window and timed auto-off

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.