Les comparto a ustedes un bonito efecto que podemos agregar a nuestras ventanas desde VB.Net. En algunos sistemas operativos (ejemplo Mac OSX) al ingresar nuestro usuario y contraseña y este es equivocado, la ventana se "sacude" o mueve de un lado a otro. Pues bien, esto mismo lo podemos imitar desde este código fuente. Sigan leyendo este tema para averiguar como hacerlo.
La funcionalidad consiste en tres funciones que desplazan la ventana en una dirección o en otra, solo debemos pasar los parámetros adecuados:
Publicidad
Función drawFxEarthQuakeToWindow con los parámetros window que es la referencia a la ventana que deseamos mover, direction es la dirección hacia donde se sacudirá la ventana: 1 de forma horizontal, 2 de forma vertical y cualquier otro numero sera igual a moverse de forma horizontal. Por ultimo times el numero de veces que deseamos que se mueva la ventana.
Solo integren esta código en su programa, invoquen la función en question y listo. Dejo un video como muestra de la funcionalidad sobre una ventana de un proyecto.
'#### Purpose: Earth quake in the window!!!!!!!!!!!
'#### Created date: 03/03/2012
'#### Created by username: Juan Manuel Mar Hdz.
'#### Last modified date: 17/17/2015
'#### Last modified username: Juan Manuel Mar Hdz.
'#### Thanks to http://www.forosdelweb.com/wiki/Efecto:_%22terremoto%22_en_el_navegador
Public Sub drawFxEarthQuakeToWindow(window As Form, direction As Long, Optional times As Long = 3)
Select Case direction
Case 1
xdirectionearthquake(window, 3)
Case 2
ydirectionearthquake(window, 3)
Case Else
xdirectionearthquake(window, 3)
End Select
End Sub
'#### Purpose: Earth quake in the window!!!!!!!!!!!
'#### Created date: 03/03/2012
'#### Created by username: Juan Manuel Mar Hdz.
'#### Last modified date: 27/01/2014
'#### Last modified username: Juan Manuel Mar Hdz.
'#### Inspired in http://www.forosdelweb.com/wiki/Efecto:_%22terremoto%22_en_el_navegador
'#### Thanks to http://bytes.com/topic/visual-basic-net/answers/369242-how-can-i-make-my-vb-net-program-sleep-5-minutes
Private Sub xdirectionearthquake(window As Form, times As Long)
Dim i As Long, j As Long, myspace As Long = 2, movetimes As Long = 4
Dim winleft As Long, sleeptime As Long = 25
winleft = window.Left
For j = 1 To times - 1
window.Left = winleft
For i = 1 To movetimes
window.Left = window.Left + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = movetimes To 1 Step -1
window.Left = window.Left - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = 1 To (-1 * movetimes) Step -1
window.Left = window.Left - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = (-1 * movetimes) To 1
window.Left = window.Left + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
Next
End Sub
'#### Purpose: Earth quake in the window!!!!!!!!!!!
'#### Created date: 10/03/2012
'#### Created by username: Juan Manuel Mar Hdz.
'#### Last modified date: 27/01/2014
'#### Last modified username: Juan Manuel Mar Hdz.
'#### Inspired in http://www.forosdelweb.com/wiki/Efecto:_%22terremoto%22_en_el_navegador
'#### Thanks to http://bytes.com/topic/visual-basic-net/answers/369242-how-can-i-make-my-vb-net-program-sleep-5-minutes
Private Sub ydirectionearthquake(window As Form, times As Long)
Dim i As Long, j As Long, myspace As Long = 2, movetimes As Long = 4
Dim winleft As Long, sleeptime As Long = 25
winleft = window.Top
For j = 1 To times - 1
window.Top = winleft
For i = 1 To movetimes
window.Top = window.Top + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = movetimes To 1 Step -1
window.Top = window.Top - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = 1 To (-1 * movetimes) Step -1
window.Top = window.Top - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = (-1 * movetimes) To 1
window.Top = window.Top + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
Next
End Sub
¿Te gustó este post?, entonces si lo deseas puedes apoyarnos para continuar con nuestra labor, gracias.
La funcionalidad consiste en tres funciones que desplazan la ventana en una dirección o en otra, solo debemos pasar los parámetros adecuados:
Función drawFxEarthQuakeToWindow con los parámetros window que es la referencia a la ventana que deseamos mover, direction es la dirección hacia donde se sacudirá la ventana: 1 de forma horizontal, 2 de forma vertical y cualquier otro numero sera igual a moverse de forma horizontal. Por ultimo times el numero de veces que deseamos que se mueva la ventana.
Solo integren esta código en su programa, invoquen la función en question y listo. Dejo un video como muestra de la funcionalidad sobre una ventana de un proyecto.
'#### Purpose: Earth quake in the window!!!!!!!!!!!
'#### Created date: 03/03/2012
'#### Created by username: Juan Manuel Mar Hdz.
'#### Last modified date: 17/17/2015
'#### Last modified username: Juan Manuel Mar Hdz.
'#### Thanks to http://www.forosdelweb.com/wiki/Efecto:_%22terremoto%22_en_el_navegador
Public Sub drawFxEarthQuakeToWindow(window As Form, direction As Long, Optional times As Long = 3)
Select Case direction
Case 1
xdirectionearthquake(window, 3)
Case 2
ydirectionearthquake(window, 3)
Case Else
xdirectionearthquake(window, 3)
End Select
End Sub
'#### Purpose: Earth quake in the window!!!!!!!!!!!
'#### Created date: 03/03/2012
'#### Created by username: Juan Manuel Mar Hdz.
'#### Last modified date: 27/01/2014
'#### Last modified username: Juan Manuel Mar Hdz.
'#### Inspired in http://www.forosdelweb.com/wiki/Efecto:_%22terremoto%22_en_el_navegador
'#### Thanks to http://bytes.com/topic/visual-basic-net/answers/369242-how-can-i-make-my-vb-net-program-sleep-5-minutes
Private Sub xdirectionearthquake(window As Form, times As Long)
Dim i As Long, j As Long, myspace As Long = 2, movetimes As Long = 4
Dim winleft As Long, sleeptime As Long = 25
winleft = window.Left
For j = 1 To times - 1
window.Left = winleft
For i = 1 To movetimes
window.Left = window.Left + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = movetimes To 1 Step -1
window.Left = window.Left - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = 1 To (-1 * movetimes) Step -1
window.Left = window.Left - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = (-1 * movetimes) To 1
window.Left = window.Left + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
Next
End Sub
'#### Purpose: Earth quake in the window!!!!!!!!!!!
'#### Created date: 10/03/2012
'#### Created by username: Juan Manuel Mar Hdz.
'#### Last modified date: 27/01/2014
'#### Last modified username: Juan Manuel Mar Hdz.
'#### Inspired in http://www.forosdelweb.com/wiki/Efecto:_%22terremoto%22_en_el_navegador
'#### Thanks to http://bytes.com/topic/visual-basic-net/answers/369242-how-can-i-make-my-vb-net-program-sleep-5-minutes
Private Sub ydirectionearthquake(window As Form, times As Long)
Dim i As Long, j As Long, myspace As Long = 2, movetimes As Long = 4
Dim winleft As Long, sleeptime As Long = 25
winleft = window.Top
For j = 1 To times - 1
window.Top = winleft
For i = 1 To movetimes
window.Top = window.Top + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = movetimes To 1 Step -1
window.Top = window.Top - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = 1 To (-1 * movetimes) Step -1
window.Top = window.Top - (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
For i = (-1 * movetimes) To 1
window.Top = window.Top + (i * myspace)
System.Threading.Thread.Sleep(sleeptime)
Next
Next
End Sub
Procedencia de las imágenes: |
File: Ejemplo de una ventana en VB.Net URL: http://3.bp.blogspot.com/-p4WDZGPYZtQ/Uhv4c2NCrGI/AAAAAAAADKc/QsRcSGqtbaw/s320/image001-786527.png Licencia: Creative Commons. |
¿Te gustó este post?, entonces si lo deseas puedes apoyarnos para continuar con nuestra labor, gracias.
No hay comentarios. :
Publicar un comentario