Dewa Weblog

memberikan apa yang dapa diberikan,berbagi satu untuk semua

Untuk Mempercantik sebuah Aplikasi dengan VB terkadang kita sulit untuk menerapkan apa yang kita inginkan dengan form aplikasi kita dan disini saya mencoba membagi bagaimna cara mempercantik form yaitu dengan membuat form pada aplikasi kita menjadi Transparant....!!! :)

langsung ke cara pembuatannya aja dech :
1. Buka Vb loe...
2. 1 buah Form
3. dan tambahkan 1 Module
Masukin code berikut
'======================================================
'Code In Module
'===================================================
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 color 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 SetTranslucent(ThehWnd As Long, nTrans As Integer)
On Error GoTo ErrorRtn
Dim attrib As Long
attrib = GetWindowLong(ThehWnd, GWL_EXSTYLE)
SetWindowLong ThehWnd, GWL_EXSTYLE, attrib Or WS_EX_LAYERED
SetLayeredWindowAttributes ThehWnd, RGB(255, 255, 0), nTrans, LWA_ALPHA
Exit Sub
ErrorRtn:
MsgBox Err.Description & " Source : " & Err.Source
End Sub
'========================== FINISH=====================================
'=====================================================================
'COde In FORM
'=====================================================================
' Declaration
Option ExplicitDim g_nTransparency As Integer
Private Declare Function SystemParametersInfo Lib _"user32" Alias "SystemParametersInfoA" (ByVal _uAction As Long, ByVal uParam As Long, lpvParam _As Any, ByVal fuWinIni As Long) As Long
Private Const SPI_SCREENSAVERRUNNING = 97&


Private Sub Form_Load()
On Error GoTo ErrorRtn
Dim X As Long
Dim Y As Boolean
X = SystemParametersInfo(SPI_SCREENSAVERRUNNING, _True, Y, 0&)
_nTransparency = 50
if g_nTransparency < g_ntransparency =" 0">
If g_nTransparency > 255 Then g_nTransparency = 255
SetTranslucent Me.hwnd, g_nTransparency
Exit Sub
ErrorRtn:
MsgBox Err.Description & " Source : " & Err.Source
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim X As Long
Dim Y As Boolean
X = SystemParametersInfo(SPI_SCREENSAVERRUNNING, _ False, Y, 0&)
End Sub
Pada saat dijalankan ini lah hasil Transparant yang dibuat

untuk selengkapnya silahkan download disini http://www.mediafire.com/?72jdozxtmmw

dibuat oleh : Dewa

0 komentar

Post a Comment