Friday, May 6, 2011

Membuat splash screen menggunakan Visual Basic


Tutorial ini aku tulis untuk melengkapi tutorial membuat program autorun dengan visual basic. Langkah pertama yang harus dilakukan adalah menyiapkan gambar yang akan digunakan saat splash screen muncul. Contoh gambar yang aku buat adalah seperti ini.
Kemudian masukkan PictureBox ke dalam form, kemudian cari pilihan Picture dalam properties Picture1. Masukkan gambar yang kamu buat sebelumnya. Pastikkan ukuran gambar dan PictureBox sama agar terlihat pas/cocok.
Kemudian tambahkan sebuah Timer dan beri Interval = 1. Setelah itu untuk membercantik tampilan, buatlah sebuah Label dan beri Caption Loading . . .
Setelah itu klik kanan pada toolbar dan pilih Component.
Kemudian pilih AeroSuit ActiveX Controls dan klik OK.
Kemudian letakkan sebuah AeroProgressBar pada form kamu. Atau seperti contoh berikut.
Setelah itu masukkan coding berikut.

Option Explicit
Dim a As Integer

Private Sub Form_Load()
MakeTransparent Me.hwnd, 0
Timer1.Enabled = True
a = 0
End Sub
Private Sub Timer1_Timer()
a = a + 5
If a <= 1500 Then
MakeTransparent Me.hwnd, a
Else
MakeTransparent Me.hwnd, 255
Timer1.Enabled = False
Me.Hide
End If
End Sub

Kemudian buatlah sebuah Modul dengan klik kanan pada folder Forms>Add>Module seperti contoh berikut ini.
Kemudian masukkan coding di bawah ini ke dalam Modul.

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 < 0 Or 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

Silahkan run programmu dan splash screen akan muncul. Selamat mencoba. Semoga berhasil.

1 comment:

  1. Casino Slot Machine - DrmCD
    The Best Casino 과천 출장마사지 Slot 서산 출장마사지 Machines on www.casino.org/Slot 구리 출장마사지 machines | Online slot machines · 태백 출장샵 Popular Casino Slot Machines 평택 출장안마 | Popular Casino Slot Machines

    ReplyDelete

Thanks for your comment.

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More