模仿QQ窗口收入窗体内


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

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        int state;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
            this.Top = 0;
            state = 0;
        }

        private void Form1_MouseEnter(object sender, EventArgs e)
        {
            if (state == 0)
            {
                state = 1;
                int t = this.Top;
                for (int i = t; i <= 0; i++)
                {
                    this.Top = i;
                    Application.DoEvents();
                }
                state = 0;
            }
        }

        private void Form1_MouseLeave(object sender, EventArgs e)
        {
            if (this.Top <= 0 && state==0)
            {
                state = 1;
                int t=this.Top;
                for (int i = t; i > -this.Height + 10; i--)
                {
                    this.Top = i;
                    Application.DoEvents();
                }
                state = 0;
            }
        }
    }
}
原文地址:https://www.cnblogs.com/MasonRayn/p/3375361.html