C#實(shí)現(xiàn)QQ窗口抖動(dòng)效果
更新時(shí)間:2020年11月24日 14:02:29 作者:IT-Xu_LongTeng
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)QQ窗口抖動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了C#實(shí)現(xiàn)QQ窗口抖動(dòng)效果的具體代碼,供大家參考,具體內(nèi)容如下
實(shí)現(xiàn)界面:
1. 兩個(gè)textbook和兩個(gè)Button
2. NotifyIcon控件是實(shí)現(xiàn)托盤
實(shí)現(xiàn)代碼:
private void Form1_Load(object sender, EventArgs e) { this.Text = "聊天窗口"; button1.Text = "抖動(dòng)"; button2.Text = "發(fā)送"; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; textBox1.ReadOnly = true; //獲取焦點(diǎn)在textBox2上面用來發(fā)送消息 textBox2.TabIndex = 0; x = this.Left; y = this.Top; //設(shè)置窗口中某個(gè)按鈕可以同Enter鍵進(jìn)行控制效果 this.AcceptButton = button2; } int x, y; int t=30, space = 3; private void Button1_Click(object sender, EventArgs e) { for (int i=0;i<2 ;i++ ) { this.Location = new Point(x - space, y); Thread.Sleep(t); this.Location = new Point(x - space, y - space); Thread.Sleep(t); this.Location = new Point(x, y - space); Thread.Sleep(t); this.Location = new Point(x + space, y - space); Thread.Sleep(t); this.Location = new Point(x + space, y); Thread.Sleep(t); this.Location = new Point(x + space, y + space); Thread.Sleep(t); this.Location = new Point(x, y + space); Thread.Sleep(t); this.Location = new Point(x - space, y + space); Thread.Sleep(t); this.Location = new Point(x - space, y); Thread.Sleep(t); this.Location = new Point(x, y); } } private void Button2_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(textBox2.Text)==false) { textBox1.Text += DateTime.Now + "\r\n" + textBox2.Text + "\r\n"; textBox2.Text = ""; } } //resize窗口尺寸變動(dòng) private void Form1_Resize(object sender, EventArgs e) { //最小化到系統(tǒng)托盤 if (this.WindowState==FormWindowState.Minimized) { this.ShowInTaskba=false; } } //Close關(guān)閉窗口 private void NotifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { this.ShowInTaskba=true; this.WindowState=FormWindowState.Normal; }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
相關(guān)文章
C#創(chuàng)建安全的棧(Stack)存儲(chǔ)結(jié)構(gòu)
這篇文章主要為大家詳細(xì)介紹了C#創(chuàng)建安全的棧(Stack)存儲(chǔ)結(jié)構(gòu)的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-10-10- 本文主要介紹了C#中利用GDI來繪制圖形和文字的方法,并提供的簡單的示例供大家參考學(xué)習(xí),希望能夠?qū)Υ蠹矣兴鶐椭?/div> 2016-03-03
C#實(shí)現(xiàn)定時(shí)任務(wù)Task Scheduler的示例代碼
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)定時(shí)任務(wù)Task Scheduler的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-02-02最新評論