zoukankan      html  css  js  c++  java
  • WinForm特效:同时让两个窗体有激活效果

    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);
    
            }
    
        }
    
    }

  • 相关阅读:
    hexo博客安装教程
    MySQL 索引
    linux笔记
    Matab:plot图形操作
    Verilog--DC
    Verilog--二进制编码到格雷码的转换
    Undefined symbol SystemInit (referred from startup_stm32f10x_md.o).
    电源设计
    蓝牙通信
    quartus II的USB Blaster驱动器安装
  • 原文地址:https://www.cnblogs.com/cl1024cl/p/6204911.html
Copyright © 2011-2022 走看看