Membuat form transparat


Berikut ini adalah cara membuat form menjadi transparat dengan VB.

buat modul dengan nama mdlTransX
ketik pada module

‘ — begin —
option explicit

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

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 ShowWindow Lib “user32” (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Public Declare Function SetLayeredWindowAttributes Lib “user32.dll” (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlag As Long) As Long

Public Const GWL_EXSTYLE As Long = -20
Public Const WS_EX_LAYERED As Long = &H80000
Public Const LWA_ALPHA As Long = &H2

Public Function transparant(hwnd As Long, persen As Integer, pilih As Boolean)
Dim sebelumnya As Long
sebelumnya = GetWindowLong(hwnd, GWL_EXSTYLE)
If pilih = True Then
sebelumnya = sebelumnya Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, sebelumnya
SetLayeredWindowAttributes hwnd, 0, 255 * (persen / 100), LWA_ALPHA
Else
sebelumnya = sebelumnya And Not WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, sebelumnya
End If
End Function

‘ — end of module

ketik pada form
Private sub form_load()
mdlTransX.transparant me.hwnd, 80, true
end sub

About

Flexter member

Posted in VB 6.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: