WinForm implements an instance of the effect of having two forms active simultaneously

Source: Internet
Author: User

The examples in this article describe the effects that WinForm implements to make two forms active at the same time. The main use of Windows API implementation of a form when the activation of a message to send another. Share to everyone for your reference.

The implementation method is as follows:

Using system;using system.windows.forms;using system.runtime.interopservices;namespace WindowsApplication43{Public    Partial class Form1:form {Form frm =null;      Public Form1 () {InitializeComponent (); This.    Activated + = form_activated;    } const int wm_ncactivate = 0x86;    const int wa_active = 0x1; [DllImport ("user32.dll", EntryPoint = "SendMessage")] public static extern int SendMessage (IntPtr hWnd, int wmsg, int w    Param, int lParam);      private void Button1_Click (object sender, EventArgs e) {frm = new Form (); frm.      Text = "Jinjazz"; frm.      Activated + = form_activated; frm.      Show (); frm. Location = new System.Drawing.Point (this. Left + this. Width, this.      TOP); SendMessage (this.    Handle, Wm_ncactivate, wa_active, 0); } void Form_activated (object sender, EventArgs e) {SendMessage (this.      Handle, Wm_ncactivate, wa_active, 0); if (frm! = null) SendMessage (frm.    Handle, Wm_ncactivate, wa_active, 0); }  }}

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration, Running GuestArticles are original, reproduced please link to the form of the address of this article
WinForm implements an instance of the effect of having two forms active simultaneously

This address: http://www.paobuke.com/develop/c-develop/pbk23467.html






Related content WinForm example of how to extract content using regular expressions C # 3 kinds of Effects C # format string implementation code c#êμ?? 3ìdò?a?ú??? ˉμ?? ¨
The timer in C # and its garbage collection mechanism C # implements voice video recording-with demo source C # Implements a method of disrupting the order of elements in an array C # methods for parsing JSON into datetable

WinForm implements an instance of the effect of having two forms active simultaneously

Related Article

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.