?? 用c#實現類似qq的簡單通訊程序.htm
字號:
false;<BR><BR>
listenPort += new ThreadStart(this.Listen);<BR>
lister = new
Thread(listenPort);<BR>
this.Closing += new
System.ComponentModel.CancelEventHandler(abortLister);<BR>
Initializenotifyicon();<BR>
//<BR> //
TODO: 在 InitializeComponent 調用后添加任何構造函數代碼<BR>
//<BR>
}<BR> #region 初始化托盤組件<BR>
private void Initializenotifyicon()<BR>
{<BR>
NotifyIcon1 = new NotifyIcon();<BR>
NotifyIcon1.Icon = img;<BR>
NotifyIcon1.Text = "局域網聊天程序";<BR>
NotifyIcon1.Visible =
true;<BR>
NotifyIcon1.DoubleClick += new
EventHandler(this.showMainForm);<BR><BR>
MenuItem [] menuArray = new
MenuItem[3];<BR>
menuArray[0] = new MenuItem();<BR>
menuArray[0].Text = "顯示主窗口";<BR>
menuArray[0].Click += new
EventHandler(this.showMainForm);<BR>
menuArray[0].DefaultItem = true;<BR><BR>
menuArray[1] = new
MenuItem("-");<BR><BR>
menuArray[2] = new MenuItem();<BR>
menuArray[2].Text = "退出";<BR>
menuArray[2].Click += new
EventHandler(this.exitSystem);<BR><BR>
nMenu = new ContextMenu(menuArray);<BR>
NotifyIcon1.ContextMenu =
nMenu;<BR> }
<BR> //顯示主窗口<BR>
private void showMainForm(object sender,System.EventArgs
e)<BR> {<BR>
this.WindowState =
System.Windows.Forms.FormWindowState.Normal;
<BR>
}<BR> //退出程序<BR>
private void exitSystem(object sender,System.EventArgs
e)<BR> {<BR>
NotifyIcon1.Visible = false;<BR>
this.Close();<BR>
}<BR> #endregion<BR>
/// <summary><BR>
/// 清理所有正在使用的資源。<BR> ///
</summary><BR> protected override
void Dispose( bool disposing )<BR>
{<BR> if( disposing
)<BR> {<BR>
if
(components != null) <BR>
{<BR>
components.Dispose();<BR>
}<BR>
}<BR>
base.Dispose( disposing );
<BR> }<BR>
#region Windows 窗體設計器生成的代碼<BR> ///
<summary><BR> /// 設計器支持所需的方法 -
不要使用代碼編輯器修改<BR> /// 此方法的內容。<BR>
/// </summary><BR>
private void InitializeComponent()<BR>
{<BR>
this.label1 = new System.Windows.Forms.Label();<BR>
this.txtIp = new
System.Windows.Forms.TextBox();<BR>
this.txtRecord = new
System.Windows.Forms.TextBox();<BR>
this.label2 = new
System.Windows.Forms.Label();<BR>
this.txtName = new
System.Windows.Forms.TextBox();<BR>
this.btnSend = new
System.Windows.Forms.Button();<BR>
this.txtContent = new
System.Windows.Forms.TextBox();<BR>
this.label3 = new
System.Windows.Forms.Label();<BR>
this.SuspendLayout();<BR>
// <BR>
// label1<BR>
// <BR>
this.label1.Location = new System.Drawing.Point(16, 232);<BR>
this.label1.Name =
"label1";<BR>
this.label1.Size = new System.Drawing.Size(72, 23);<BR>
this.label1.TabIndex =
0;<BR>
this.label1.Text = "目標地址:";<BR>
this.label1.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter;<BR>
// <BR>
// txtIp<BR>
// <BR>
this.txtIp.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left
| System.Windows.Forms.AnchorStyles.Right)));<BR>
this.txtIp.Location = new
System.Drawing.Point(80, 232);<BR>
this.txtIp.Name = "txtIp";<BR>
this.txtIp.Size = new
System.Drawing.Size(200, 21);<BR>
this.txtIp.TabIndex = 1;<BR>
this.txtIp.Text = "";<BR>
// <BR>
// txtRecord<BR>
// <BR>
this.txtRecord.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left
| System.Windows.Forms.AnchorStyles.Right)));<BR>
this.txtRecord.Location = new
System.Drawing.Point(16, 32);<BR>
this.txtRecord.Multiline = true;<BR>
this.txtRecord.Name =
"txtRecord";<BR>
this.txtRecord.ReadOnly = true;<BR>
this.txtRecord.ScrollBars =
System.Windows.Forms.ScrollBars.Vertical;<BR>
this.txtRecord.Size = new
System.Drawing.Size(264, 176);<BR>
this.txtRecord.TabIndex = 4;<BR>
this.txtRecord.Text = "";<BR>
// <BR>
// label2<BR>
// <BR>
this.label2.Location = new
System.Drawing.Point(24, 256);<BR>
this.label2.Name = "label2";<BR>
this.label2.Size = new
System.Drawing.Size(48, 23);<BR>
this.label2.TabIndex = 5;<BR>
this.label2.Text = "呢 稱:";<BR>
this.label2.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter;<BR>
// <BR>
// txtName<BR>
// <BR>
this.txtName.Location = new
System.Drawing.Point(80, 256);<BR>
this.txtName.Name = "txtName";<BR>
this.txtName.Size = new
System.Drawing.Size(88, 21);<BR>
this.txtName.TabIndex = 6;<BR>
this.txtName.Text = "";<BR>
// <BR>
// btnSend<BR>
// <BR>
this.btnSend.Location = new
System.Drawing.Point(200, 256);<BR>
this.btnSend.Name = "btnSend";<BR>
this.btnSend.Size = new
System.Drawing.Size(64, 23);<BR>
this.btnSend.TabIndex = 0;<BR>
this.btnSend.Text = "發 送";<BR>
this.btnSend.Click += new
System.EventHandler(this.btnSend_Click);<BR>
// <BR>
// txtContent<BR>
// <BR>
this.txtContent.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left) <BR>
|
System.Windows.Forms.AnchorStyles.Right)));<BR>
this.txtContent.Location = new
System.Drawing.Point(16, 288);<BR>
this.txtContent.Multiline = true;<BR>
this.txtContent.Name =
"txtContent";<BR>
this.txtContent.Size = new System.Drawing.Size(264, 152);<BR>
this.txtContent.TabIndex =
8;<BR>
this.txtContent.Text = "";<BR>
// <BR>
// label3<BR>
// <BR>
this.label3.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left) <BR>
|
System.Windows.Forms.AnchorStyles.Right)));<BR>
this.label3.Location = new
System.Drawing.Point(16, 8);<BR>
this.label3.Name = "label3";<BR>
this.label3.Size = new
System.Drawing.Size(100, 16);<BR>
this.label3.TabIndex = 9;<BR>
this.label3.Text = "聊天記錄:";<BR>
this.label3.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft;<BR>
// <BR>
// MainForm<BR>
// <BR>
this.AutoScaleBaseSize = new System.Drawing.Size(6,
14);<BR>
this.ClientSize = new System.Drawing.Size(292, 453);<BR>
this.Controls.Add(this.label3);<BR>
this.Controls.Add(this.txtContent);<BR>
this.Controls.Add(this.btnSend);<BR>
this.Controls.Add(this.txtName);<BR>
this.Controls.Add(this.label2);<BR>
this.Controls.Add(this.txtRecord);<BR>
this.Controls.Add(this.txtIp);<BR>
this.Controls.Add(this.label1);<BR>
this.Name = "MainForm";
<BR>
this.Text = "局域網聊天程序";<BR>
this.Load += new
System.EventHandler(this.MainForm_Load);<BR>
this.ResumeLayout(false);<BR><BR>
}<BR>
#endregion<BR> ///
<summary><BR> ///
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -