zoukankan      html  css  js  c++  java
  • 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";
  • 相关阅读:
    webpack-dev-server
    python 基础语言 学习笔记
    react 避免重复渲染
    获取cookie
    解决 canvas 在高清屏中绘制模糊的问题
    h5页面点击事件ios没反应 移动端兼容性问题
    rem 刷新闪烁问题
    谷歌禁止input自动填充表单信息
    react 循环产生定时器
    IOS开发-UI学习-UIWebView,简单浏览器的制作
  • 原文地址:https://www.cnblogs.com/sung/p/3269930.html
Copyright © 2011-2022 走看看