2012年1月27日 星期五

視窗半透明

Option Explicit

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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 Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2

Private Function TranslucentForm(frmhwnd As Long, TranslucenceLevel As Byte) As Boolean

SetWindowLong frmhwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes frmhwnd, 0, TranslucenceLevel, LWA_ALPHA
TranslucentForm = Err.LastDllError = 0
End Function




Private Sub Form_Load()
TranslucentForm Me.hwnd, 200 '最高255 0則完全透明'
End Sub

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。