Advertise with us
Control Panel
Forum
Hosting Help
ASP.NET 4.5 & SQL 2012 Hosting
Resources
Notice
Login
Members
Shared Hosting
|
Upgrade
|
Advertise
|
Tutorials
|
Home
»
Resources
»
¡Atrapa el botón!
ASP.NET
ADO.NET
Web Services
Remoting
Visual Studio 2005
Error Bank
Interview Questions
Tips & Tricks
XML
HTML
Jscript/Javascript
IIS
Windows
General
Submit Resource or code snippet
... and get
surprise gifts
Win Digital camera, ASP.NET Books, Free softwares!!
¡Atrapa el botón!
21 Jan, 2008
Author:
transporte terrestrre
Summary
Mover un control al mover el ratón sobre el.
.NET Classes used :
Esta es una chorradilla que he visto en un programa hecho por Lars Johansson (TidySharp).
El tipo este en un formulario de esos "acerca de" tiene un botón al que no se le puede hacer click, al menos con el ratón, ya que pulsando la tecla Intro se cierra.
El tema es que al mover el cursor del ratón sobre el botón, éste se desplaza y cambia de sitio... curioso y... ¡a ver quién pulsa sobre el botón!
Aquí tienes el código para VB .NET y C#.
En ambos casos, se supone que el botón "a perseguir" se llama buttonOK y se le ha asignado el método mostrado al evento MouseMove.
En el caso de VB simplemente habría que añadir al final de la primera línea lo siguiente:
Handles buttonOK.MouseMove
En C#, habrá que crear el evento para ese botón con una línea como esta:
this.buttonOK.MouseMove += new System.Windows.Forms.MouseEventHandler(this.buttonOK_MouseMove);
codigo para VB.NET
Private Soid buttonOK_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs)
Dim r As New Random()
Dim x As Integer = CInt(Me.ClientRectangle.Right * r.NextDouble()) -30
Dim y As Integer = CInt(Me.ClientRectangle.Bottom * r.NextDouble() )-10
buttonOK.Location = New Point(x, y)
End Sub
CODIGO PARA C#
private void buttonOK_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Random r = new Random();
int x = (int)(this.ClientRectangle.Right * r.NextDouble() ) -30;
int y = (int)(this.ClientRectangle.Bottom * r.NextDouble() )-10;
buttonOK.Location = new Point(x, y);
}
(fuente: elguille.info)
Feedbacks about this page from members:
- No Feedbacks yet !! -
Submit Feedback
View All Feedbacks
Total
members
:
250723
Average new registrations per day (in last 7 days):
7
New Registration:
Open
Register Now
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
Advertise
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.