前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >QQ项目之七窗体悬浮

QQ项目之七窗体悬浮

作者头像
用户9184480
发布2024-12-13 10:40:19
发布2024-12-13 10:40:19
6000
代码可运行
举报
文章被收录于专栏:云计算linux云计算linux
运行总次数:0
代码可运行
代码语言:javascript
代码运行次数: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();
            }
        }

    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-04-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档