Senin, 09 April 2012

Form Transparan Visual Basic

Kode berikut ini akan membuat Form menjadi transparan :

Buat sebuah Module baru lalu ketikkan :
Option Explicit

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 Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long


Public Sub FadeForm(ByVal Frm As Form, ByVal Level As Byte)
On Error Resume Next
Dim msg As Long

msg = GetWindowLong(Frm.hwnd, -20) Or &H80000
SetWindowLong Frm.hwnd, -20, msg
SetLayeredWindowAttributes Frm.hwnd, 0, Level, &H2
End Sub

Selanjutnya di bagian Form yang akan dijadikan transparan, di 'Form_Load' ketikkan :
FadeForm Me, 125

Tingkat transparasi dapat dirubah dengan mengganti nilai properti Level-nya (0-255).


0 komentar:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More