C # code like QQ in the lower right corner of the message box, regardless of the current user's focus in which window, the message box pop-up does not affect the change in focus, then there are two ways

Source: Internet
Author: User

You QQ in the lower right corner of the message box, regardless of the current user's focus in which window, message box pop-up does not affect the change in focus, then there are two ways:

Either rewrite the event that needs to pop up the form:

protected override CreateParams CreateParams {get {const int ws_ex_noactivate = 0x08000000; CreateParams CP = base.        CreateParams; Cp.        ExStyle |= ws_ex_noactivate;    return CP; }}//CreateParams under the System.Windows.Forms.Controls namespace

Either call the system hook:

Reference system hooks [DllImport ("User32.dll")]public static extern IntPtr GetActiveWindow ();  [DllImport ("User32.dll")] public static extern IntPtr SetActiveWindow (INTPTR hwnd); Do the following processing when the window pops up IntPtr activeForm = GetActiveWindow (); Get the current active form new Form2 first. Show (FALSE); Pop-up new form SetActiveWindow (ActiveForm); Before returning the focus to the active form


C # code like QQ in the lower right corner of the message box, regardless of the current user's focus in which window, the message box pop-up does not affect the change in focus, then there are two ways

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.