holemania
asked on
VB.NET mouseover button move
Anyone know if it's possible to create a button where if you mouseover it, the button moves away? I know it can be done in Java and have seen the code, but is it possible to create something like this in VB.NET? If so does anyone have sample code I can look and see how it's done?
Yes. Do you mean like however hard you try, the button cannot be clicked because it moves?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As abel says, of course it can be done...but is this a WinForms (Desktop) or WebForms (Browser) application?
...and do you want the button to move away as the mouse comes NEAR it?
...or make the button simply jump somewhere else when the mouse ENTERS the it?
...and do you want the button to move away as the mouse comes NEAR it?
...or make the button simply jump somewhere else when the mouse ENTERS the it?
Here's a simple example on WinForms where the cursor stays in the middle of the button and drags it around on the form. Important things to note are PostToClient/PointToScreen translations and Application.DoEvents/is_mo ving static boolean to give the application the time to draw the button.
static bool is_moving = false;
private void btnMovable_MouseMove(object sender, MouseEventArgs e)
{
if (is_moving)
return;
else
{
is_moving = true;
Point locMouse = this.PointToClient(btnMovable.PointToScreen(e.Location));
btnMovable.Location = new Point(locMouse.X - btnStartTransform.Width / 2, locMouse.Y - btnMovable.Height / 2);
Application.DoEvents();
is_moving = false;
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah wanted to move as you try to click. Thanks i'll take a look.
ASKER
Thanks that's what I was looking.