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