windows api,一个窗体激活的时候给另外一个发消息
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 wParam, 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); } } }
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索int
, 窗体
, sendmessage
, this
, system
, frm
, 窗体激活
wa
,以便于您获取更多的相关知识。
时间: 2024-12-23 01:14:48