Este post lo hice en otro foro, mas abajo se menciona para que..
Ignoren lo de "entrar al Lab" ;D
El proposito de este post es mas el de ayudar a que los users aprendan algunas funciones utiles
sobre todo las usadas para entrar al
Lab:
Que se usa:- Un timer (Nombre: Timer1)
- Case
- IIF
- If
- Funciones
- Sub's
- Variables
Si no quedo claro, :laugh: añaden un Timer, y copian el code y lo ejecutan y lo estudian ;)
No creo que haga falta la explicacion pero si hay dudas pregunten:
Dim TiempoAtenuacion As Long
Private Sub Form_Load()
TiempoAtenuacion = 10
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
Select Case TiempoAtenuacion
Case Is = 150
Timer1.Interval = 0
Timer1.Enabled = False
Me.Show
Case Else
Call Atenuar
Call SumarIntervalo
End Select
TiempoAtenuacion = Timer1.Interval
End Sub
Private Function Atenuar()
Dim Estado As String
Estado = IIf(Me.Visible, "Encendido", "Apagado")
If Estado = "Encendido" Then
Me.Hide
ElseIf Estado = "Apagado" Then
Me.Show
End If
End Function
Private Sub SumarIntervalo()
Timer1.Interval = Timer1.Interval + 5
End Sub
Espero le sirva a alguien ;)
SaluDOS!!!
Usa geshi hermano:
code=vb
Edito:
Tu código se puede optimizar bastante deja lo recreo a mi manera ( Ya pongo aquí el código):
Temibles unas!¡
.
.
Se le debe pasar 2 parámetros, 1 es una instancia de un objeto Timer X cual sea no importa y el mas importante el handle de la pantalla a darle el dicho efecto.
Se puede usar un timer creado por vía api pero bueno para evitar broncas de códigos largos lo deje con un parámetro donde se pasa el timer.
'
' ////////////////////////////////////////////////////////////////
' // Autor: BlackZeroX ( Ortega Avila Miguel Angel ) //
' // Inspirado en la idea principal de 3D1 //
' // //
' // Web: http://InfrAngeluX.Sytes.Net/ //
' // //
' // |-> Pueden Distribuir Este Codigo siempre y cuando //
' // no se eliminen los creditos originales de este codigo //
' // No importando que sea modificado/editado o engrandesido //
' // o achicado, si es en base a este codigo es requerido //
' // el agradacimiento al autor. //
' ////////////////////////////////////////////////////////////////
' // Modulo de Clase "ClsAnimateWindows" //
' ////////////////////////////////////////////////////////////////
'
Option Explicit
Private WithEvents tmr As Timer
Const SW_SHOWNORMAL = 1
Const SW_HIDE = 0
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Dim vHwnd As Long
Public Property Let Timer(vData As Timer)
Set tmr = vData
tmr.Enabled = False
End Property
Public Property Get Timer() As Timer
Set Timer = tmr
End Property
Public Property Let hWnd(vData As Long)
vHwnd = vData
End Property
Public Property Get hWnd() As Long
hWnd = vHwnd
End Property
Public Function Start() As Boolean
Start = Not tmr Is Nothing
If Start Then
tmr.Interval = 10
tmr.Enabled = True
End If
End Function
Private Sub TMR_Timer()
Static CounTim As Integer
Dim Res As Long
If CounTim >= 170 Then
CounTim = 0
Res = ShowWindow(vHwnd, SW_SHOWNORMAL)
tmr.Enabled = False
Else
Res = ShowWindow(vHwnd, Abs(Not CBool(IsWindowVisible(vHwnd))))
tmr.Interval = tmr.Interval + 10
CounTim = tmr.Interval
End If
End Sub
Private Sub Class_Terminate()
Set tmr = Nothing
End Sub
Ejemplo de su uso:
'
' ////////////////////////////////////////////////////////////////
' // Autor: BlackZeroX ( Ortega Avila Miguel Angel ) //
' // //
' // Web: http://InfrAngeluX.Sytes.Net/ //
' // //
' // |-> Pueden Distribuir Este Codigo siempre y cuando //
' // no se eliminen los creditos originales de este codigo //
' // No importando que sea modificado/editado o engrandesido //
' // o achicado, si es en base a este codigo es requerido //
' // el agradacimiento al autor. //
' ////////////////////////////////////////////////////////////////
' // Ejemplo: Modulo de Clase "ClsAnimateWindows" //
' // Se nesesita: //
' // * 1 Timer //
' ////////////////////////////////////////////////////////////////
Option Explicit
Dim AnimatW As ClsAnimateWindows
Private Sub Form_Load()
Set AnimatW = New ClsAnimateWindows
With AnimatW
.hWnd = Me.hWnd
.Timer = Timer1
.Start
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set AnimatW = Nothing
End Sub
El código al pesarla el handle de la ventana puede hacer "intermitente" cualquier ventana de windows... solo sabiendo el hwnd de dicha ventanilla xP.
aqui un ejemplo hacia un control del mismo formulario:
'
' ////////////////////////////////////////////////////////////////
' // Autor: BlackZeroX ( Ortega Avila Miguel Angel ) //
' // //
' // Web: http://InfrAngeluX.Sytes.Net/ //
' // //
' // |-> Pueden Distribuir Este Codigo siempre y cuando //
' // no se eliminen los creditos originales de este codigo //
' // No importando que sea modificado/editado o engrandesido //
' // o achicado, si es en base a este codigo es requerido //
' // el agradacimiento al autor. //
' ////////////////////////////////////////////////////////////////
' // Ejemplo: Modulo de Clase "ClsAnimateWindows" //
' // Se nesesita: //
' // * 1 Timer //
' // * 1 PictureBox //
' ////////////////////////////////////////////////////////////////
Option Explicit
Dim AnimatW As ClsAnimateWindows
Private Sub Form_Load()
Set AnimatW = New ClsAnimateWindows
With AnimatW
.hWnd = Picture1.hWnd
.Timer = Timer1
.Start
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set AnimatW = Nothing
End Sub
Temibles Lunas!¡
esto lo unico que hace es ocultar y mostrar la ventana :o
Cita de: seba123neo en 30 Enero 2010, 17:01 PM
esto lo unico que hace es ocultar y mostrar la ventana :o
Da igual se ve bonito jajaja
Temibles Lunas!¡.
.
.
La ultima actualizacion y ya me voy ya lo deje optimizado.
'
' ////////////////////////////////////////////////////////////////
' // Autor: BlackZeroX ( Ortega Avila Miguel Angel ) //
' // Inspirado en la idea principal de 3D1 //
' // //
' // Web: http://InfrAngeluX.Sytes.Net/ //
' // //
' // |-> Pueden Distribuir Este Codigo siempre y cuando //
' // no se eliminen los creditos originales de este codigo //
' // No importando que sea modificado/editado o engrandesido //
' // o achicado, si es en base a este codigo es requerido //
' // el agradacimiento al autor. //
' ////////////////////////////////////////////////////////////////
' // Modulo de Clase "ClsAnimateWindows" //
' ////////////////////////////////////////////////////////////////
'
Option Explicit
Private WithEvents tmr As Timer
Const SW_SHOWNORMAL = 1
Const SW_HIDE = 0
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Dim vHwnd As Long
Public Property Let Timer(vData As Timer)
Set tmr = vData
tmr.Enabled = False
End Property
Public Property Get Timer() As Timer
Set Timer = tmr
End Property
Public Property Let hWnd(vData As Long)
vHwnd = vData
End Property
Public Property Get hWnd() As Long
hWnd = vHwnd
End Property
Public Function Start() As Boolean
Start = Not tmr Is Nothing
If Start Then
tmr.Interval = 10
tmr.Enabled = True
End If
End Function
Private Sub TMR_Timer()
tmr.Enabled = Not tmr.Interval >= 170
If tmr.Enabled Then
ShowWindow vHwnd, Abs(Not CBool(IsWindowVisible(vHwnd)))
tmr.Interval = tmr.Interval + 10
Else
ShowWindow vHwnd, SW_SHOWNORMAL
End If
End Sub
Private Sub Class_Terminate()
Set tmr = Nothing
End Sub
Cita de: BlackZeroX▓▓▒▒░░ en 30 Enero 2010, 07:59 AM
Usa geshi hermano:
code=vb
Edito:
Tu código se puede optimizar bastante deja lo recreo a mi manera ( Ya pongo aquí el código):
Temibles unas!¡
.
No use geshi por que el algunos codes cuando contenía Tabulaciones salían como "&noseque" pero intentare en la próxima ;)
Ya se que se puede optimizar!!! :xD
Por que no leen todo el post :-(
Ahí puse el propósito del cual hice ese post, era para unas practicas para entrar al "VBLab 1" (De otro foro) el mas sencillo :)
Yo prefiero hacer algo simple como esto sin API's, ahorro muchas mas lineas :xD
Aquí mi propio code optimizado:
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Me.Visible = Switch(Timer1.Interval >= 200, True, Timer1.Interval <> 200, IIf(Me.Visible, False, True))
Timer1.Interval = Switch(Timer1.Interval < 200, Timer1.Interval + 10, True, 0)
End Sub
Colocas un Timer (Timer1) y
Copy And Paste ;)
Este debería ser el mismo ejercicio pero para el Lab 3 :xD
SaluDOS!!!
Si es por elegir... Me quedo con el mio! xD
Private Sub Form_Load()
Call Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = (Timer1.Interval + 10) Mod 200
Me.Visible = Not Me.Visible Or Timer1.Interval = 0
End Sub
Cita de: cobein en 3 Febrero 2010, 04:12 AM
Si es por elegir... Me quedo con el mio! xD
Private Sub Form_Load()
Call Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = (Timer1.Interval + 10) Mod 200
Me.Visible = Not Me.Visible Or Timer1.Interval = 0
End Sub
Eso es trampa ¬¬
XD, ok pensé en usar "Mod" pero nah, nadie usa Switch ni IIf ;D
SaluDOS!!!
PD: Lo haré en una sola linea... xD