Labels

Cari Blog Ini

Selasa, 05 Januari 2010

Make Form Transparan With VB 6.0

To make visual transparent Form in Visual basic 6.0 opening new project and enhance a modul.modul can be enhanced by click of project add module . typing code following into module.

Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long

Private Declare Function UpdateLayeredWindow Lib "user32" _
(ByVal hwnd As Long, ByVal hDCDst As Long, pptDst As Any, _
psize As Any, ByVal hDCSrc As Long, pptSrc As Any, crKey As Long, _
ByVal pblend As Long, ByVal dw
Flags 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

Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const ULW_COLORKEY = &H1
Private Const ULW_ALPHA = &H2
Private Const ULW_OPAQUE = &H4
Private Const WS_EX_LA
YERED = &H80000

Public Function MakeTransparent(ByVal hwnd As Long, Perc As Integer) As Long
Dim Msg As Long
On Error Resume Next
If Perc <> 255 Then
MakeTransparent = 1
Else
Msg = GetWindowLong(hwnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes hwnd, 0, Perc, LWA_ALPHA
MakeTransparent = 0
End If
If Err Then
MakeTransparent = 2
End If
End Function


''==========

After code in module have been typed later;then type code of following at form in Event load.

Private sub Form_load()

MakeTransparent Me.hwnd, 150

‘150 รจ can be altered - alter.

End sub

Running form by pressing F5

Result it like picture following.

0 komentar:

Posting Komentar