Membuat Splash Screen di VB

Posted on

Mungkin kalian pernah melihat tampilan aplikasi yang muculnya secara halus saat pertama kali di jalankan / tampilan welcome(biasanya disebut splash), sekarang saya akan coba bagaimana caranya membuat splash dengan menggunakan bahasa pemrograman vb6.


Buatlah form untuk tampilan depan (welcome) sebagus mungkin, setelah itu kita buat module dengan cara klik project -> Add Module -> pilih module -> klik open

kalau sudah masukkan koding splash seperti dibawah ini :

Option Explicit

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 Declare Function UpdateLayeredWindow Lib “user32” (ByVal Hwnd As Long, ByVal hDCDst As Long, pptDst As Any, psize As Any, ByVal hDCSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, 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 Function SetWindowLong Lib “user32” Alias “SetWindowLongA” (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const ULW_COLORKEY = &H1
Private Const ULW_ALPHA = &H2
Private Const ULW_OPAQUE = &H4
Private Const WS_EX_LAYERED = &H80000

Public Function isTransparent(ByVal Hwnd As Long) As Boolean
On Error Resume Next
Dim Msg As Long
Msg = GetWindowLong(Hwnd, GWL_EXSTYLE)
If (Msg And WS_EX_LAYERED) = WS_EX_LAYERED Then
isTransparent = True
Else
isTransparent = False
End If
If Err Then
isTransparent = False
End If
End Function

Public Function MakeTransparent(ByVal Hwnd As Long, Perc As Integer) As Long
Dim Msg As Long
On Error Resume Next
If Perc 255 Then
MakeTransparent = 1
Else
Msg = GetWindowLong(Hwnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong Hwnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes Hwnd, 0, Perc, LWA_ALPHA
MakeTransparent = 0
End If
If Err Then
MakeTransparent = 2
End If
End Function

Public Function MakeOpaque(ByVal Hwnd As Long) As Long
Dim Msg As Long
On Error Resume Next
Msg = GetWindowLong(Hwnd, GWL_EXSTYLE)
Msg = Msg And Not WS_EX_LAYERED
SetWindowLong Hwnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes Hwnd, 0, 0, LWA_ALPHA
MakeOpaque = 0
If Err Then
MakeOpaque = 2
End If
End Function

Jika sudah masuklah ke dalam form welcome yang tadi kita buat kemudian masukkan koding di paling atas penulisan kode program.

Option Explicit
Dim fadin As Integer 'fadin adalah nama variablenya

kemudian tambahkan lah 1 buah objek timer dan seting interval timer sesuai keinginan kita (1000 = 1 detik), setelah menyeting sekarang masuk kedalam koding timer dan ketikkan

fadin = fadin + 10
If fadin <= 400 Then
MakeTransparent Me.Hwnd, fadin
Else
MakeTransparent Me.Hwnd, 255
Timer1.Enabled = False
End If

Jika sudah melakukan langkah yang diatas, langkah yang terakhir adalah dengan menambahkan beberapa koding di form_load.

MakeTransparent Me.Hwnd, 0
Timer1.Enabled = True
fadin = 0

Langkah terakhir sudah dilakukan sekarang tinggal menjalankan aplikasinya,

Jika mau download project yang sudah jadi bisa di ambil disini

selamat mencoba… 😀

One thought on “Membuat Splash Screen di VB

    fahrul said:
    29 December 2010 at 12:02 pm

    thax bos.. dah mau berbagi hehe
    dah lama ngak buka VB

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s