Buat form Transparant di Visual Basic 6.0

Bingung gimana cara buat form di visual basic transparant. nih gua share cara membuat nya.



Oke langsung aja :

1.  Buka vb6 dan pilih standart.exe
2. buat 1 buah form, 1 module
3. cara buat form (project ==> add form), dan buat module (project ==> add module)
4. Kemudian isikan kode ini di module.
   
   Private Declare Function _
SetLayeredWindowAttributes Lib "user32.dll" _
(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

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

Public Sub SetLayeredWindow(ByVal hwnd _
As Long, ByVal bIslayered As Boolean)
Dim WinInfo As Long
WinInfo = GetWindowLong(hwnd, -20)
If bIslayered = True Then
WinInfo = WinInfo Or 524288
Else
WinInfo = WinInfo And Not 524288
End If
SetWindowLong hwnd, -20, WinInfo
End Sub

Public Sub SetTransparan(ByVal hwnd _
As Long, ByVal Opacity As Byte, _
IsTransparent As Boolean)
If IsTransparent = True Then
SetLayeredWindow hwnd, True
SetLayeredWindowAttributes hwnd, _
0, Opacity, 2
ElseIf IsTransparent = False Then
SetLayeredWindow hwnd, False
End If
End Sub


5.  Dan isikan kode ini di Form
   
   Private Sub Form_Load()
   SetTransparan Me.hwnd, 200, True
   End Sub

6. Kemudian, coba dengan menekan F5

7. Selesai dehh... Selamat Mencoba :D

0 komentar:

Posting Komentar

Created By Andi Hakim. Diberdayakan oleh Blogger.