views:

124

answers:

1

i have a little form that looks like this in vb.net

http://img11.imageshack.us/img11/5651/samplennk.jpg

you know how you can set the windows taskbar to appear and disappear when the position of the mouse is all the way at the bottom? i want to do the same thing with my form when the mouse is in the top left corner of screen.

or perhaps you can suggest to me a different way to do this. the user will probably just need to set those trackbars just several times during their usage.

+2  A: 

You could just have a thread that checks Cursor.Position and when it's 0,0 have the form appear.

This is a little rough, but set the initial form window state to minimized.

public partial class Form1 : Form
{
    private delegate void ShowFormDel();
    private readonly ShowFormDel _ShowFormDel;
    private bool _CheckForMouse;

    public Form1()
    {
        InitializeComponent();
        _CheckForMouse = true;
        _ShowFormDel = ShowForm;
        Thread x = new Thread(CheckMouseThread);
        x.Start();
    }

    public void CheckMouseThread()
    {
        while (_CheckForMouse)
        {
            if (Cursor.Position.X < 5 && Cursor.Position.Y < 5)
            {
                this.Invoke(_ShowFormDel);
            }
            Thread.Sleep(1000);
        }
    }

    private void ShowForm()
    {
        this.Location = new Point(0, 0);
        this.WindowState = FormWindowState.Normal;
        this.Activate();
        this.Visible = true;
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        _CheckForMouse = false;
    }

    private void Form1_MouseLeave(object sender, System.EventArgs e)
    {
        this.WindowState = FormWindowState.Minimized;
    }
}
AKoran
hey very nice but could you put it in vb.net?
I__
I haven't touched VB in a long time, sorry, you are on your own! Shouldn't be that hard to convert.
AKoran