QQ项目之七窗体悬浮
  TEZNKK3IfmPf 2023年11月15日 14 0
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();
            }
        }

    }
}
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月15日 0

暂无评论

TEZNKK3IfmPf