WinForm實現(xiàn)同時讓兩個窗體有激活效果的特效實例
更新時間:2014年09月25日 10:36:44 投稿:shichen2014
這篇文章主要介紹了WinForm實現(xiàn)同時讓兩個窗體有激活效果的特效實例,基于windows api實現(xiàn)一個窗體激活的時候給另外一個發(fā)消息的特效,在進行C#項目開發(fā)時有一定的實用價值,需要的朋友可以參考下
本文實例講述了WinForm實現(xiàn)同時讓兩個窗體有激活效果的特效。主要采用windows api實現(xiàn)一個窗體激活的時候給另外一個發(fā)消息。分享給大家供大家參考。
具體實現(xiàn)方法如下:
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); } } }
希望本文所述對大家的C#程序設計有所幫助。
您可能感興趣的文章:
- WinForm實現(xiàn)窗體最大化并遮蓋任務欄的方法
- C#實現(xiàn)WinForm禁止最大化、最小化、雙擊標題欄、雙擊圖標等操作的方法
- Winform實現(xiàn)鼠標可穿透的窗體鏤空效果
- Winform窗體效果實例分析
- WinForm實現(xiàn)自定義右下角提示效果的方法
- WinForm實現(xiàn)仿視頻播放器左下角滾動新聞效果的方法
- C#實現(xiàn)winform漸變效果的方法
- C# WinForm實現(xiàn)Win7 Aero透明效果代碼
- winform下實現(xiàn)win7 Aero磨砂效果實現(xiàn)代碼
- 用 C# Winform做出全透明的磨砂玻璃窗體效果代碼
- WinForm實現(xiàn)狀態(tài)欄跑馬燈效果的方法示例
相關文章
C#開發(fā)Windows服務實例之實現(xiàn)禁止QQ運行
這篇文章主要介紹了通過C#開發(fā)Windows服務,查殺qq進程的服務功能,需要的朋友可以參考下2013-10-10