Teknik AlphaBlend Visual Basic 6.0

Diposting oleh fitri-ariyanto on Tuesday, March 04, 2008

Teknik AlphaBlend merupakan sebuah animasi ketika proses atau aplikasi mulai load atau berjalan. Dengan berupa muncul sedikit demi sedikit ataupun menghilang sedikit demi sedikit. Teknik ini dapat memperindah program yang anda buat!

Anda boleh memodifikasi sedemikian hingga..terserah anda dan kreatifitas anda

Okey sekarang kita mulai

Project yang dibutuhkan
a/. 1 Form dengan Properties Form Visible = False
b/. 2 Timer dengan Properties Intervalnya masing-masing = 100 and Enabled = False

//* Code Start *//

Option Explicit

Const LWA_BOTH = 3
Const LWA_ALPHA = 2
Const LWA_COLORKEY = 1
Const GWL_EXSTYLE = -20
Const WS_EX_LAYERED = &H80000

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 color As Long, ByVal x As Byte, ByVal alpha As Long) As Boolean

Dim TransparanDonk As Integer

Sub Transparan(hWndBro As Long, TransBro As Integer)
On Error Resume Next

Dim OKBro As Long
OKBro = GetWindowLong(hWndBro, GWL_EXSTYLE)

SetWindowLong hWndBro, GWL_EXSTYLE, OKBro Or WS_EX_LAYERED
SetLayeredWindowAttributes hWndBro, RGB(255, 255, 0), TransBro, LWA_ALPHA
Exit Sub

End Sub

Private Sub Form_Load()
Timer1.Enabled = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
Timer1.Enabled = False
Timer2.Enabled = True
End Sub

Private Sub Timer1_Timer()
On Error Resume Next
TransparanDonk = TransparanDonk + 5
If TransparanDonk > 255 Then TransparanDonk = 255: Timer1.Enabled = False
Transparan Me.hWnd, TransparanDonk
Me.Show
End Sub

Private Sub Timer2_Timer()
On Error Resume Next
TransparanDonk = TransparanDonk - 5
If TransparanDonk < 0 Then TransparanDonk = 0: Timer2.Enabled = False: End Transparan Me.hWnd, TransparanDonk
End Sub

//* End Of File *//


NB: Jangan lupa kasih Komentar ya..saran, kritik

{ 1 COMMENTS... read them below or add one }

zigan said...

boleh2... ntar ak coba ya boz....
mmm.. gak pke komponen tambahan kan??

Oh iya klo isa tambahin penjelasan programnya... biar newbie kayak ak cepet ngeh gituu.. thanks..


mampir ke blogku yaw..
http://arekpe.blogspot.com