Senin, 13 Juli 2009

Form Transparan

Senin, 13 Juli 2009
Deskripsi : Tips berikut ini adalah bagaimana Form terlihat Transparan sehingga yang terlihat hanyalah Gambar Backgroundnya saja!

'*******************
'* Form Transparan *
'*******************
'Email : ryan20shinichi@gmail.com
'Facebook : Shinichi Ryan
'--------------------------------
'Komponen Yang dibutuhkan :
'1. 1 Project & 1 Form
'2. 1 Module
'Sebelumnya Atur Nilai Properties Form nya sbb:
'1. Ubah BackColor --> Biru
'2. Ubah BorderStyle ---> 0-None
'3. Masukkan Gambar dgn Extension .gif



'Koding di Form
'--------- Batas Awal ----------

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


Private Sub Label1_Click()
End
End Sub
'--------- Batas Akhir ---------- '


'Koding di Module
'--------- Batas Awal ----------
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
'--------- Batas Akhir ----------

0 komentar:

 
Welcome To Shinichi Ryan ◄Design by Pocket, BlogBulk Blogger Templates