示例#1
0
 private void frendLv_MouseDown(object sender, MouseEventArgs e)
 {
     //用来释放被当前线程中某个窗口捕获的光标
     PubCls.ReleaseCapture();
     //向Windows发送拖动窗体的消息
     PubCls.SendMessage(this.Handle, PubCls.WM_SYSCOMMAND, PubCls.SC_MOVE + PubCls.HTCAPTION, 0);
 }
示例#2
0
        public Main_Frm()
        {
            InitializeComponent();

            //控制ListVIew的行距和列距
            //70为行距,120为列距(跟图片大小有关)
            PubCls.SendMessage(this.friendLv.Handle, PubCls.LVM_SETICONAPACING, 0, 0x10000 * 70 + 130);
        }
示例#3
0
        /// 实时获取未读消息的定时器
        private void MsgTim_Tick(object sender, EventArgs e)
        {
            //获取鼠标在屏幕的坐标点
            Point pp = new Point(Cursor.Position.X, Cursor.Position.Y);
            //存储当前窗体在屏幕的所在区域
            Rectangle rect = new Rectangle(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);

            //当鼠标在当前窗体内,并且窗体的Top属性小于0
            if (this.Top < 0 && PubCls.PtInRect(ref rect, pp))
            {
                this.Top = 0;
            }
            else
            if (this.Top > -5 && this.Top < 5 && !PubCls.PtInRect(ref rect, pp)) //当窗体的上边框与屏幕的顶端的距离小于5时
            {
                this.Top = 5 - this.Height;                                      //将QQ窗体隐藏到屏幕的顶端
            }
            JudgeSelected();

            int messageTypeID = 1; //消息类型
            int messageState  = 1; //消息状态
            //查找未读消息对应的好友ID
            string        sqlStr     = "select top 1 FromUserID, MessageTypeID, MessageState from tb_Message where ToUserID=" + PubCls.loginID + " and MessageState=0";
            SqlDataReader dataReader = dataOprt.GetDataReader(sqlStr);

            //读取未读消息
            if (dataReader.Read())
            {
                fromUserID    = (int)dataReader["FromUserID"];    //记录消息发送者
                messageTypeID = (int)dataReader["MessageTypeID"]; //记录消息类型
                messageState  = (int)dataReader["MessageState"];  //记录消息状态
            }
            dataReader.Close();
            dataOprt.CloseCnn();
            //消息有两种类型:聊天消息、添加好友消息
            //判断消息类型,如果是添加好友消息,启动消息提醒定时器
            if (messageTypeID == 2 && messageState == 0)
            {
                SoundPlayer player = new SoundPlayer("system.wav");
                player.Play();
                addFriendTim.Start();
            }
            else if (messageTypeID == 1 && messageState == 0)   //如果是聊天消息,启动聊天定时器,使好友头像闪烁
            {
                //获取消息发送者的ID
                sqlStr       = "select HeadID from tb_User where ID=" + fromUserID;
                friendHeadID = dataOprt.ExecSQL(sqlStr);    //设置发消息好友的头像ID
                //如果发消息的人不在好友列表中,将其添加到陌生人列表中
                if (!HasShowUser(fromUserID))
                {
                    UpdateStranger(fromUserID);                  //显示陌生人列表
                }
                SoundPlayer player = new SoundPlayer("msg.wav"); //聊天消息提示
                player.Play();                                   //播放指定声音文件
                chatTim.Start();                                 //启动聊天定时器
            }
        }