C#在Winform程序中显示QQ在线状态

首先,引入必要的命名空间

using System.Windows.Forms;  using System.Net;

其次,在Form中拖入一个PictureBox控件,并设置其SizeMode为AutoSize。同时拖入一个Timer控件。

然后在窗体构造函数中写入代码

timer1.Tag = 0;
timer1.Interval = 10;
timer1.Enabled = true;

然后在Timer的Tick事件中写入代码

Timer timer = (Timer)sender; if (timer.Tag != null)
{     if ((int)timer.Tag == 0)     {         timer.Enabled = false;         timer.Tag = 1;         try         {             Image img = Image.FromStream(WebRequest.Create(qqgif).GetResponse().GetResponseStream());             pictureBox1.Image = img;         }         catch         {             pictureBox1.Image = Properties.Resources.pa;         }         timer.Interval = 1000 * 10;         timer.Enabled = true;     }      else     {         try         {             Image img = Image.FromStream(WebRequest.Create(qqgif).GetResponse().GetResponseStream());             pictureBox1.Image = img;         }         catch         {             pictureBox1.Image = Properties.Resources.pa;         }     }
}

最后,在PictureBox的Click事件中写入代码

System.Diagnostics.Process.Start("iexplore.exe", qqmsg);

以上代码中 qqgif和qqmsg 的定义

private const string qqgif = "http://wpa.qq.com/pa?p=2:303071318:50"; private const string qqmsg = "tencent://message/?uin=303071318";

转载于:https://www.cnblogs.com/sung/p/3269930.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值