熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

WinForm特效:同時讓兩個窗體有激活效果

2013-11-13 10:06:51  來源: .NET編程 

  windows api一個窗體激活的時候給另外一個發消息

  using System;
        using SystemWindowsForms;
        using SystemRuntimeInteropServices;
        namespace WindowsApplication
        {
            public partial class Form : Form
            {
                Form frm =null;
                public Form()
                {
                    InitializeComponent();
                    thisActivated += Form_Activated;
                }
                const int WM_NCACTIVATE = x;
                const int WA_ACTIVE = x;
                [DllImport(userdll EntryPoint = SendMessage)]
                public static extern int SendMessage(IntPtr hWnd int wMsg int wParam int lParam);
                private void button_Click(object sender EventArgs e)
                {
                    frm = new Form();
                    frmText = jinjazz;
                    frmActivated += Form_Activated;
                    frmShow();
                    frmLocation = new SystemDrawingPoint(thisLeft + thisWidth thisTop);
                    SendMessage(thisHandle WM_NCACTIVATE WA_ACTIVE );
                }
                void Form_Activated(object sender EventArgs e)
                {
                    SendMessage(thisHandle WM_NCACTIVATE WA_ACTIVE );
                    if (frm != null)
                        SendMessage(frmHandle WM_NCACTIVATE WA_ACTIVE );
                }
            }
        }


From:http://tw.wingwit.com/Article/program/net/201311/12596.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.