1.06.2008

Form Transparan

Form Transparan

  1. Buka VB(visual basic) dengan form baru

  2. Ubah propertis BackColor form dengan warna biru, BorderStyle form menjadi 0-None. Masukan gambar pada Picture form sesuai selera

  3. Tambahkan modul dalam project, kemudian ketiklah perintah di bawah ini


Option Explicit

Public Const LWA_COLORKEY = 1

Public Const LWA_ALPHA = 2

Public Const LWA_BOTH = 3

Public Const WS_EX_LAYERED = &H80000

Public Const GWL_EXSTYLE = -20

Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal warna As Long, ByVal X As Byte, ByVal alpha As Long) As Boolean

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long


Sub SetTransparan(frm As Long, warna As Long, nTrans As Integer, flag As Byte)

On Error GoTo Err


Dim attrib As Long

attrib = GetWindowLong(frm, GWL_EXSTYLE)

SetWindowLong frm, GWL_EXSTYLE, attrib Or WS_EX_LAYERED

SetLayeredWindowAttributes frm, warna, nTrans, flag

Exit Sub

Err:

MsgBox Err.Description & " Source : " & Err.Source

End Sub


  1. Kembali ke form desain, klik ganda pada area form. Ubahlah prosedur Form_Load menjadi Form_Active. Ketiklah perintah dibawah ini pada bagian General dan Form_Active.


Option Explicit

Dim color As Long, flag As Byte


Private Sub Form_Activate()

On Error GoTo Err

color = vbBlue

flag = flag Or LWA_COLORKEY

SetTransparan Form1.hwnd, color, 0, flag

Exit Sub

Err: MsgBox Err.Description & " Source : " & Err.Source

End Sub


  1. Tekan F5 untuk melihat hasilnya.


Tidak ada komentar:

Posting Komentar

Silahkan tinggalkan komentar anda di sini...
makasih ya uda kasih komentar...
sering - sering maen sini ya...
No SaRa, No PoLiTiCs, No SPaMMiNG!!!