WinForm实现同时让两个窗体有激活效果的特效实例
2021-04-25 09:51
标签:cti public 代码 nta nbsp ref demo 窗体 normal 本文实例讲述了WinForm实现同时让两个窗体有激活效果的特效。主要采用windows api实现一个窗体激活的时候给另外一个发消息。分享给大家供大家参考。 具体实现方法如下: 希望本文所述对大家的C#程序设计有所帮助。 本文地址: http://www.paobuke.com/develop/c-develop/pbk23467.html WinForm实现同时让两个窗体有激活效果的特效实例 标签:cti public 代码 nta nbsp ref demo 窗体 normal 原文地址:http://www.cnblogs.com/paobuke/p/7920020.htmlusing 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);
}
}
}
WinForm实现同时让两个窗体有激活效果的特效实例相关内容
下一篇:C#判断某程序是否运行的方法
文章标题:WinForm实现同时让两个窗体有激活效果的特效实例
文章链接:http://soscw.com/index.php/essay/79342.html