Selasa, 15 November 2011

Membuat Form Transparan

Membuat form transparan itu mudah
Caranya:
Buka Vb. 6
Pilh Standar Exe
Klik View ->Code
Tulis Code Ini:
Option Explicit

Private Const GWL_EXSTYLE      As Long = (-20)
Private Const WS_EX_LAYERED    As Long = &H80000
Private Const LWA_ALPHA        As Long = &H2
Private Declare Function GetWindowLongA Lib "USER32" (ByVal hwnd As Long, _
                                                      ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "USER32" (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 Sub Form_Load()
Opacity 150, Me  ' angka 150 yaitu ketransparan form ini semakin kecil maka semakin transparan| Min 20 max 255
MsgBox "By Sahala/Ardan" & vbCrLf & _
       "Always Visit My Blog" & vbCrLf & _
       "http://sahalaww.blogspot.com/", vbInformation, "OK"
End Sub

Private Sub Opacity(Value As Byte, _
                    Frm As Form)
Dim MaxVal As Byte
Dim MinVal As Byte

    On Error GoTo ErrorHandler
    MinVal = 20
    MaxVal = 255
    If Value > MaxVal Then
        Value = MaxVal
    End If
    If Value < MinVal Then
        Value = MinVal
    End If
   SetWindowLongA Frm.hwnd, GWL_EXSTYLE, GetWindowLongA(Frm.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    SetLayeredWindowAttributes Frm.hwnd, 0, Value, LWA_ALPHA
ErrorHandler:

Exit Sub

End Sub
'By Sahala/Ardan Copyright 2011
Setelah Code Dimasukan Lalu klik Run->Start(F5)
Bagi yang Ingin Projectnya 
Download

0 komentar:

Posting Komentar



Pengunjung yang baik harus meninggalkan komentar
Komentar:Dilarang sara, kata-kata tdk pantas , SPAM Dsb

Friends Blog