26. juli 2004 - 13:47
Der er
6 kommentarer og
1 løsning
FadeIn med Timer, eller bedre?
Hej eksperter!
Jeg har et Class Module som kan gøre mit program transparent i VB 6.0 Med for eks. "c.Opacity = 255"
Nu vil jeg gerne bruge det til at fade mine forms ind/ud med, skal jeg gøre det med en timer? eller hvordan?
prøv den her..
'--------------------------- Form1 ---------------------------
Option Explicit
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Activate()
Dim lCount As Long
Do While lCount < 255
lCount = (lCount + 1)
DoEvents
SetLayeredWindowAttributes Me.hWnd, 0, lCount, LWA_ALPHA
Loop
End Sub
Private Sub Form_Load()
Dim lStyle As Long
lStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, lStyle
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim lCount As Long
lCount = 255
Do While lCount > 0
lCount = (lCount - 1)
DoEvents
SetLayeredWindowAttributes Me.hWnd, 0, lCount, LWA_ALPHA
Loop
End Sub
'--------------------------- Form1 ---------------------------