Selasa, 14 Desember 2010
2
[VB] Form Load Dan Unload Secara Samar-Samar (Fade)
Ok sobat, kali ini saya iseng-iseng membuat sebuah program yang form nya ketika di close tampak samar-samar lalu secara perlahan menghilang (Fading)
Source Code:
 
 
Deklarasi: 1 Form
Source Code:
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 crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub MakeTaskbarTransparent(LhWnd As Long, ByVal bLevel As Byte)
On Error GoTo Salah
    Dim lOldStyle As Long
    
    If (LhWnd <> 0) Then
        lOldStyle = GetWindowLong(LhWnd, (-20))
        SetWindowLong LhWnd, (-20), lOldStyle Or &H80000
        SetLayeredWindowAttributes LhWnd, 0, bLevel, &H2&
    End If
Salah:
End Sub
Sub FadeForm(hWnd As Long, Optional FadeOut As Boolean = True)
Dim i As Integer
If FadeOut Then
   For i = 1 To 15
     DoEvents
     MakeTaskbarTransparent hWnd, i * 17
     Sleep 100
   Next i
Else
    For i = 1 To 15
      DoEvents
      MakeTaskbarTransparent hWnd, Int(255 / i)
      Sleep 100
    Next i
End If
End Sub
Private Sub Form_Load()
  Load Form1
  Form1.Show
  Form1.Refresh
  FadeForm Form1.hWnd, True
End Sub
Private Sub Form_Unload(Cancel As Integer)
  FadeForm Form1.hWnd, False
End Sub
' Adapted from AVIGEN VB Bego
' Thanx to VB Bego Team for this nice code
' 2010 Crowja-Coderz
Langganan:
Posting Komentar (Atom)
 



 
2 Komentar Untuk “[VB] Form Load Dan Unload Secara Samar-Samar (Fade)”
Senin, 09 Mei 2011 pukul 10.47.00 WIB
mantap fren........
trima kasih karna tlah membagi ilmuny....
Senin, 09 Mei 2011 pukul 12.22.00 WIB
@Anonim sma2 fren,,, ilmu memang untk d bgi2...ckckck,,, sring2 brkunjung y... ^_^
Posting Komentar
Berikan komentar positif tentang artikel yang sederhana ini niscaya sobat akan mendapatkan balasannya. Hehehe