C#實現(xiàn)QQ窗口抖動效果
更新時間:2020年11月24日 14:02:29 作者:IT-Xu_LongTeng
這篇文章主要為大家詳細(xì)介紹了C#實現(xiàn)QQ窗口抖動效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了C#實現(xiàn)QQ窗口抖動效果的具體代碼,供大家參考,具體內(nèi)容如下
實現(xiàn)界面:
1. 兩個textbook和兩個Button
2. NotifyIcon控件是實現(xiàn)托盤

實現(xiàn)代碼:
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "聊天窗口";
button1.Text = "抖動";
button2.Text = "發(fā)送";
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
textBox1.ReadOnly = true;
//獲取焦點在textBox2上面用來發(fā)送消息
textBox2.TabIndex = 0;
x = this.Left;
y = this.Top;
//設(shè)置窗口中某個按鈕可以同Enter鍵進行控制效果
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窗口尺寸變動
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)文章
輕松學(xué)習(xí)C#的結(jié)構(gòu)和類
輕松學(xué)習(xí)C#的結(jié)構(gòu)和類,對C#的結(jié)構(gòu)和類感興趣的朋友可以參考本篇文章,幫助大家更靈活的運用C#的結(jié)構(gòu)和類2015-11-11
C# 實現(xiàn)dataGridView選中一行右鍵出現(xiàn)菜單的示例代碼
這篇文章主要介紹了C# 實現(xiàn)dataGridView選中一行右鍵出現(xiàn)菜單,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-09-09
C#實現(xiàn)將千分位字符串轉(zhuǎn)換成數(shù)字的方法
這篇文章主要介紹了C#實現(xiàn)將千分位字符串轉(zhuǎn)換成數(shù)字的方法,很適合初學(xué)者更好的理解C#字符串原理,需要的朋友可以參考下2014-08-08
使用C# 調(diào)用deepseek api接口實現(xiàn)正常訪問的過程
本文介紹了使用C#調(diào)用deepseek API接口實現(xiàn)正常訪問的方法,包括解決SSL/TLS安全通道問題和切換模型等常見問題,并提供了默認(rèn)使用的reasoner模型和賬戶余額信息,感興趣的朋友一起看看吧2025-02-02

