Membuat Form VB unikMembuat Form VB unik

Rabu, 13 Januari 2010

Membuat Form VB unik


Trik ini untuk membuat form dengan bentuk-bentuk gambar sebagai background form program, sehingga bentuk form akan mengikuti gambar background. dengan trik ini kita dapat menghasilkan bentuk-bentuk yang aneh dan unik. pokok nya gag standar deh hehehehe

bagaimana cara membuatnya????

dalam pembuatan form ini kita membutuhkan gambar harus dalam fotmat bmp atau gif, sebab kalau dengan format jpg maka tidak akan berhasil.
selain itu yang perlu diperhatikan adalah backcolor pada form harus diset warna bitu tua (&H00FF0000&) karena bagian tersebut yang akan dihilangkan dengan memfilter warna biru tersebut.

untuk lebih jelasnya ikuti langkah-langkah berikut :
1. buka proyek baru dengan jenis halaman standart exe
2. set backcolor form menjadi warna biru (&H00FF0000&)
3. insert gambar yang telah disiapkan sebagai background
3. buat modul baru dengan cara klik project terus add module
4. pada modul ketikkan script berikut :


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

5. setelah selesai membuat module kemudian tulis script pada form
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
6. test program anda dengan mengklik run start atau F5
7. berharap saja tidak terjadi eror heheheheh


link untuk mendownload contoh program ini download membuat form unik vb

1 komentar: