首页 > 代码库 > WinForm特效:同时让两个窗体有激活效果
WinForm特效:同时让两个窗体有激活效果
windows api,一个窗体激活的时候给另外一个发消息
[csharp] view plaincopy
- 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);
- }
- }
- }
WinForm特效:同时让两个窗体有激活效果
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。