View Single Post
Old 07-02-2009   #4 (permalink)
Christian Treffler


 
 

Re: Button Cotrol: Event, when mouse leaves button with mousebutten still down

Christian Treffler schrieb:
Quote:

> Jack Jackson schrieb:
>
Quote:

>> I think the best you can do is to check in MouseMove if the mouse
>> cursor is over the button or not.
>
> Thanks,
> I'll try that. Will probably not work without some delayed actions on
> the screen, but better than nothing.
OK, that was not so difficult:

public static void BtnMove(object sender, MouseEventArgs e)
// Handler to check, if button is left with mouse down
{
Button btn = (Button)sender;
if (e.X < 0 || // Mouse Pointer not within button rectangle?
e.Y < 0 ||
e.X > btn.Size.Width ||
e.Y > btn.Size.Height)
{
int[] i = (int[])btn.Tag; // get index list
btn.ImageIndex = i[0]; // #0 is for normal state
}
else if (e.Button == MouseButtons.Left)
// else check, if button is still down
{
int[] i = (int[])btn.Tag; // get index list
btn.ImageIndex = i[1]; // #1 is for button down
}
}

Thanks for your tip.

CU,
Christian
My System SpecsSystem Spec