Form, Opacity, mouseHover.

B

Boki

Hi All,

I saw the paint.net program, when mouse hover, the color palette
become 100% opacity.

I try the code below, the issue is I also have some other controls
( textbox/button ) in my form, it should be a better way to do it in
fewer codes, right ?

( set all hover function to the same as form ? )

/* CODE */


private void Form1_MouseHover(object sender, EventArgs e)
{
this.Opacity = 1;

}

private void Form1_MouseLeave(object sender, EventArgs e)
{
this.Opacity = 0.7;
}

/* CODE */

Best regards,
Boki.
 
B

Boki

Hi All,

I saw the paint.net program, when mouse hover, the color palette
become 100% opacity.

I try the code below, the issue is I also have some other controls
( textbox/button ) in my form, it should be a better way to do it in
fewer codes, right ?

( set all hover function to the same as form ? )

/* CODE */

private void Form1_MouseHover(object sender, EventArgs e)
{
this.Opacity = 1;

}

private void Form1_MouseLeave(object sender, EventArgs e)
{
this.Opacity = 0.7;
}

/* CODE */

Best regards,
Boki.

I have tried to setup all hover function pointer to same one. but got
latency, no good result.

Boki.
 
H

herr

I had the same problem, but finally leaved the whole thing to a timer that
monitors the mouse location each 10 millisecond and changes the form opacity
if the mouse is over the form or not:


// Method to see if the cursor is over your form or not:

private bool HitTest(Form frm)
{
if (Cursor.Position.X < frm.Width + frm.Left && Cursor.Position.X >
frm.Left)
{

if (Cursor.Position.Y < frm.Height+ frm.Top && Cursor.Position.Y >
frm.Top)
{
return true;

}
}
return false;
}

// Create Timer that monitors cursor location each 10 millisecond and name
it "timerOpacity"
// then:

private void timerOpacity_Tick(object sender, EventArgs e)
{
if (HitTest(this))
{
this.Opacity = 1.0;
}
else
{
this.Opacity = 0.4;
}
}
 
B

Boki

I had the same problem, but finally leaved the whole thing to a timer that
monitors the mouse location each 10 millisecond and changes the form opacity
if the mouse is over the form or not:

// Method to see if the cursor is over your form or not:

private bool HitTest(Form frm)
{
if (Cursor.Position.X < frm.Width + frm.Left && Cursor.Position.X >
frm.Left)
{

if (Cursor.Position.Y < frm.Height+ frm.Top && Cursor.Position.Y >
frm.Top)
{
return true;

}
}
return false;

}

// Create Timer that monitors cursor location each 10 millisecond and name
it "timerOpacity"
// then:

private void timerOpacity_Tick(object sender, EventArgs e)
{
if (HitTest(this))
{
this.Opacity = 1.0;
}
else
{
this.Opacity = 0.4;
}

}

Thanks, I think it is doable.

But I still thinking the Paint.Net implementation, it works well, and
I think they didn't use a timer to check it.
I am wondering if any other methods. :)

Boki.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top