private void btncomponente_MouseEnter(object sender, EventArgs e)
{
//coordenadas
Point xy
= new Point
(Cursor
.Position.X, Cursor
.Position.Y); Point raton
= new Point
(this.PointToClient(xy
).X,
this.PointToClient(xy
).Y);
Point OrigenBtn
= new Point
(btncomponente
.Location.X, btncomponente
.Location.Y); //Puntos Basicos del boton
Point IzqSup
= new Point
(OrigenBtn
.X, OrigenBtn
.Y); Point DerInf
= new Point
(OrigenBtn
.X + btncomponente
.Height, OrigenBtn
.Y + btncomponente
.Width);
if (raton.X >= IzqSup.X && raton.X < IzqSup.X + 5)
{
btncomponente.SetBounds(btncomponente.Left + 10, btncomponente.Top,
btncomponente.Width, btncomponente.Height);
//Mover botno derecha 10px
}
if (raton.X > DerInf.X - 5 && raton.X <= DerInf.X)
{
btncomponente.SetBounds(btncomponente.Left - 10, btncomponente.Top,
btncomponente.Width, btncomponente.Height);
//Mover botno IZQUIERDA 10px
}
if (raton.Y >= IzqSup.Y && raton.Y < IzqSup.Y + 5)
{
btncomponente.SetBounds(btncomponente.Left , btncomponente.Top + 10,
btncomponente.Width, btncomponente.Height);
//Mover botno ABAJO 10px
}
if (raton.Y > DerInf.Y - 5 && raton.Y <= DerInf.Y)
{
btncomponente.SetBounds(btncomponente.Left, btncomponente.Top - 10,
btncomponente.Width, btncomponente.Height);
//Mover botno ARRIBA 10px
}
}