QQ项目之七窗体悬浮

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MYQQ
{
    public partial class FrmUserInformation : Form
    {
        public Point point;
        public FrmUserInformation()
        {
            InitializeComponent();            
        }
        

        //悬浮至好友Q名时
        private void lblChatName_MouseEnter(object sender, EventArgs e)
        {
            lblName.Font = new Font("微软雅黑", 16F, FontStyle.Underline);
        }

        //离开好友Q名时
        private void lblChatName_MouseLeave(object sender, EventArgs e)
        {
            lblName.Font = new Font("宋体", 9F);
        }

        //窗口加载时
        private void FrmInformation_Load(object sender, EventArgs e)
        {
            //初始化窗口出现位置
            this.Location = point;
            lblName.Text = UserHelper.myNickName;
        }

        //窗体重绘时
        private void FrmUserInformation_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            SolidBrush sb = new SolidBrush(Color.FromArgb(100, 255, 255, 255));
            g.FillRectangle(sb, new Rectangle(new Point(1, Height - 103), new Size(Width - 2, 80)));
        }

        #region 渐变效果

        public bool isOpend = false;
        /// <summary>
        /// 隐藏
        /// </summary>
        public new void Hide()
        {
            timHide.Enabled = true;
            
        }
        public new void Show() {
            this.Location = point;
            timShow.Enabled = true;           
        }
        #endregion

        /*
         代码思路:隐藏的时候,让窗体渐渐的隐藏,开始的时候,窗体渐渐显示;
         
         */
        #region 总计时器

        //计时器
        private void timShow_Tick(object sender, EventArgs e)
        {
            base.Show();
            if (this.Opacity <1)
            {
                this.Opacity = this.Opacity + 0.1;
            }
            if (this.Opacity == 1.0)
            {
                timShow.Enabled = false;    
            }
        }

        #endregion

        private void timHide_Tick(object sender, EventArgs e)
        {
            if (this.Opacity > 0)
            {
                this.Opacity = this.Opacity - 0.1;
            }
            if (this.Opacity == 0.0)
            {
                timHide.Enabled = false;                
                base.Hide();
            }
        }

    }
}

转载于:https://www.cnblogs.com/mjsn/p/6150997.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值