Click here to Skip to main content
15,887,962 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
namespace slide2view
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
            this.Top = Screen.PrimaryScreen.WorkingArea.Top - this.Height + 1;
        }

        private void tmSlide_Tick(object sender, EventArgs e)
        {
            Point pos = Control.MousePosition;
            bool inForm = pos.X >= this.Left && pos.Y >= this.Top && pos.X < this.Right && pos.Y < this.Bottom && this.Top <= Screen.PrimaryScreen.WorkingArea.Top - 1;
            if ( inForm)
                this.Top += 5;
        }        

        private void tmSlideUp_Tick(object sender, EventArgs e)
        {
            Point pos = Control.MousePosition;
            bool inForm = pos.X < this.Left && pos.Y < this.Top && pos.X > this.Right && pos.Y > this.Bottom && this.Top >= Screen.PrimaryScreen.WorkingArea.Top + 1;
            if (inForm)
                this.Top -= 5;
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            this.tmSlide.Enabled = true;
            this.tmSlideUp.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.tmSlide.Enabled = false;
            this.tmSlideUp.Enabled = true;
        }
    }
}


What I have tried:

I have tried using a bool other than inform to check if the mouse has left the form. I tried mouse leave, I tried Focus() and lost_focus. The form doesnt budge to hide.
Posted
Comments
BillWoodruff 26-Jul-16 23:58pm    
Please add to your "code dump" a simple clear statement about what it is you are to do. Is this WinForms ? Is there a Main Form ? Are there other Forms ? What Form creates "other Forms."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900