有新的信息有托盘提示
来源:互联网 发布:js犀牛 视频教程下载 编辑:程序博客网 时间:2024/04/27 01:17
using System;
using System.IO;
using System.Net;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private bool m_bFlag = true;
//根据Url地址得到网页的HTML源码
private string GetWebContent(string Url)
{
string strResult = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
//声明一个HttpWebRequest请求
request.Timeout = 30000;
//设置连接超时时间
request.Headers.Set("Pragma", "no-cache");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream streamReceive = response.GetResponseStream();
Encoding encoding = Encoding.GetEncoding("gb2312");
StreamReader streamReader = new StreamReader(streamReceive, encoding);
strResult = streamReader.ReadToEnd();
streamReader.Close();
}
catch
{
MessageBox.Show("出错");
}
return strResult;
}
public Form1()
{
InitializeComponent();
this.notifyIcon1.Icon = new Icon("1.ico");
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
this.timer2.Enabled = true;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
}
private void Form1_SizeChanged(object sender, System.EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
}
}
//关闭
private void toolStripMenuItem4_Click(object sender, System.EventArgs e)
{
this.Close();
}
//显示
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();
this.timer1.Stop();
this.notifyIcon1.Icon = new Icon("1.ico");
}
}
//抓
private void timer2_Tick(object sender, System.EventArgs e)
{
//抓取数据
string Url = "http://192.168.2.27:91/admin/Admin_User.asp";
string strWebContent = GetWebContent(Url);
FileStream fs = new FileStream(@"1.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string strData = sr.ReadToEnd();
sr.Close();
fs.Close();
if (strWebContent != strData)
{
this.webBrowser1.Refresh();
this.timer1.Start();
this.timer1.Tick += new EventHandler(this.timer1_Tick);
StreamWriter sw = new StreamWriter("1.txt");
sw.Write(strWebContent);
sw.Close();
}
}
//闪
private void timer1_Tick(object sender, System.EventArgs e)
{
if (m_bFlag)
{
this.notifyIcon1.Icon = new Icon("2.ico");
m_bFlag = false;
}
else
{
this.notifyIcon1.Icon = new Icon("1.ico");
m_bFlag = true;
}
}
}
}
- 有新的信息有托盘提示
- 有新的通知的时候提示
- 有新的订单,刷新并有提示音
- webIM项目中,有新消息时,滚动窗体的title提示有信息消息
- textBox输入时下边有提示信息
- VC如何作出有动画效果的托盘图标
- 任务栏托盘不消失的问题-有启发
- 新的一年有新的开始
- 如何实现Video Record的时候来新的MMS 仍然可以有提示
- 有选择的忽略PyCharm 3的PEP8语言风格警告提示信息
- 软件更新提示(检查app store 软件是否有新的版本)---需要app id
- 如何实现鼠标移动到CCombox控件有详细的提示信息
- Flex List 选项变灰,信息过长有提示,修复dragComplete事件不准的BUG
- IntelliJ-IDEA CheckStyle提示信息是有乱码
- 关闭vs2010的托盘提示
- ocx 有安全提示的问题
- 原本正确的js提示有错误
- 编写有提示的listbox控件
- 发发牢骚,记之
- 总决赛噢!今天是总决赛第一场啊!
- 您也使用托管C++吗?
- 机箱前置USB线如何与主板进行连接
- 初来扎到请多关照、呵呵
- 有新的信息有托盘提示
- 宏定义中的空格
- Copy-On-Write Access
- 35 岁前程序员要规划好的四件事 zt
- jdk1.5新特性
- 《深入理解C++对象模型》Chapter 4 Complete
- 杀软不能用,右键,双击病毒的解决
- IT、加班、围城
- 生命的力量