四川师范大学成都学院计算机网络编程实训报告
//指定托盘图标
myNotifyIcon.Icon = new Icon(\ //鼠标悬停在托盘图标上方时显示的内容 myNotifyIcon.Text = \我的聊天器\ //设置关联的上下文菜单
myNotifyIcon.ContextMenuStrip = this.contextMenuStrip1; //显示托盘图标
myNotifyIcon.Visible = true;
//添加用户双击任务栏中的托盘图标时触发的事件 myNotifyIcon.DoubleClick += new EventHandler(myNotifyIcon_DoubleClick); }
void myNotifyIcon_DoubleClick(object sender, EventArgs e) {
if (isShow) {
this.Hide(); isShow = false; } else {
this.Show(); isShow = true; } }
private void chat_FormClosing(object sender, FormClosingEventArgs e) {
if (isExit == false) {
//取消关闭窗体事件 e.Cancel = true; //隐藏窗体 this.Hide(); } else {
udpClient.Close(); } }
private void 显示窗口toolStripMenuItem1_Click(object sender, EventArgs e) {
this.Show(); }
16
四川师范大学成都学院计算机网络编程实训报告
private void 退出程序toolStripMenuItem2_Click(object sender, EventArgs e) {
isExit = true;
Application.Exit(); }
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) {
if (isShow) {
this.Hide(); isShow = false; } else {
this.Show(); isShow = true; } }
private Icon m_Icon1; private Icon m_Icon2;
private void 打开计时器ToolStripMenuItem_Click(object sender, EventArgs e) {
tmIcon.Start(); }
private void 停止计时器ToolStripMenuItem_Click(object sender, EventArgs e) {
tmIcon.Stop(); }
private void tmIcon_Tick(object sender, EventArgs e) {
if (m_Icon1 != null && m_Icon2 != null) //如果两个图标文件都被正确载入 {
//只要tmIcon被启动,则在两个图标之间不断进行选择变换,实现动画效果
if (m_bFlag == true) {
notifyIcon1.Icon = m_Icon2; m_bFlag = false; }
17
四川师范大学成都学院计算机网络编程实训报告
else {
notifyIcon1.Icon = m_Icon1; m_bFlag = true; } } }
#endregion
#region control_delegate_method
private void SetComboBox(string str) {
//去除掉cbxChoose控件选项的重复内容 cbxChoose.Items.Add(str);
for (int i = 0; i < this.cbxChoose.Items.Count; i++) {
for (int j = 0; j < this.cbxChoose.Items.Count; j++) {
if (i != j) {
if (this.cbxChoose.Items[i].ToString() == this.cbxChoose.Items[j].ToString()) {
this.cbxChoose.Items.Remove(this.cbxChoose.Items[j]); } } } } }
18
四川师范大学成都学院计算机网络编程实训报告
参考文献:
[1] (美)罗舒赫:计算机网络,清华大学出版社,2000 [2] 邓亚平:计算机网络,电子工业出版社,2001
[3] 徐武:计算机网络工程与实训教程,电子工业出版社,1997 [4] (美)克莱姆:网络管理技术构架,人民邮电出版社,1999 [5] 刘晓华:NET核心技术原理与架构,电子工业出版社,2002 [6] 王石:数据库系统开发、WEB开发,人民邮电出版社,2007 [7] 罗莉琴,詹祖桥:《Windows网络编程》,人民邮电出版社 [8] 范文庆:《Windows API开发详解》,人民邮电出版社 [9](美)杜飞:《Windows并发编程指南》,机械工业出版社
[10] David J. Kruglinski & Scot Wingo & George Shepherd:《Programming Microsoft Visual C++6.0技术内幕》,北京希望电子出版社
[11] Jeffrey Richter & Christophe Nasarre :《Windows核心编程(第五版)》,清华大学出版社
[12] 张文,赵子铭:《P2P网络技术原理与C++开发案例》,人民邮电出版社 [13] 陈坚,陈伟:《Visual C++网络高级编程》,人民邮电出版社
19