Evasive Button

Create a button that runs away from the mouse

Page 1 of 1

4 Replies - 2857 Views - Last Post: 23 May 2006 - 01:34 PM Rate Topic: -----

#1 ceejay20  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-May 06

Evasive Button

Posted 15 May 2006 - 07:03 AM

I've just started out with VB and Im enjoying it :P
But my question is, once the user clicks a command button, how do you move it around the screen, li9ke to annoy someone
Like if the command button says 'Click Me!' and they click it, it will move somewhere else ! or even if they hover over it, Like it moves before they click it ..
Thanx for reading, if you can post code samples of how i would do this, i would appreciate it

sorry if i have spelling mistakes :D

This post has been edited by born2c0de: 16 May 2006 - 06:41 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Evasive Button

#2 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Evasive Button

Posted 15 May 2006 - 09:21 AM

as annoying as the program will be, it doesn't use the common command_click method, but rather use this instead:
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Top = Rnd * (frm.ScaleHeight - Command1.Height)
Command1.Left = Rnd * (frm.ScaleWidth - Command1.Width)
End Sub


*This is for a button named command1, and a form named frm, so replace those as desired.

This will move the buton to a random position on your form, if the mouse is ever over it.
Was This Post Helpful? 0
  • +
  • -

#3 Xenon  Icon User is offline

  • Connection failed
  • member icon

Reputation: 8
  • View blog
  • Posts: 1,595
  • Joined: 12-September 05

Re: Evasive Button

Posted 16 May 2006 - 10:00 PM

William_Wilson, on 15 May, 2006 - 08:43 PM, said:

as annoying as the program will be, it doesn't use the common command_click method, but rather use this instead:
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Top = Rnd * (frm.ScaleHeight - Command1.Height)
Command1.Left = Rnd * (frm.ScaleWidth - Command1.Width)
End Sub


*This is for a button named command1, and a form named frm, so replace those as desired.

This will move the buton to a random position on your form, if the mouse is ever over it.

acutally :P its awesome that it'd move away before you can even click it, maybe it has some use somewhere.....
Was This Post Helpful? 0
  • +
  • -

#4 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Evasive Button

Posted 16 May 2006 - 11:24 PM

I've used it, but it's just annoying really in this context, but the idea has many applications elsewhere.
I've seen this method combined with some in depth ingenuity used to create an etch-a-sketch type of program :)
Was This Post Helpful? 0
  • +
  • -

#5 ceejay20  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-May 06

Re: Evasive Button

Posted 23 May 2006 - 01:34 PM

[font=Comic Sans Ms][size=3][b] FANX 4 THE HELP MiSTER .. WiLLiAM :D:D
THAT ETCH A SKETCH THiNG SOUNDS RLi KoOL :P
i KNOW iTS RLi ANNOYiN 2 BUT iTS BASiCALLi JoOST SHOWiN HOW iT WORX :S:S LoL
FANX A LOT THO (Y)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1