问个关于窗口透明度的问题

来源:百度知道 编辑:UC知道 时间:2024/06/14 07:29:28
如何把窗口按他的height来设置透明度呢。
就是height的值越少。SetLayeredWindowAttributes Me.hWnd, 0, i,LWA_ALPHA 这个里面的i的值越大。最大是255。然后当height的值满的时候。i=0。就是把窗口从上到下。越来越透明的那种样子。然后哪位大大能帮我想一下。用VB来实现。谢谢
问题解决了我再加50分

Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long

Private Function AlphaRatio(Byval iHeight As Integer, Byval iMaxHeight As Integer) As Integer
If iHeight > iMaxHeight Then iHeight = iMaxHeight
AlphaRatio = 255 - MulDiv(255, iHeight, iMaxHeight)
End Function

Private Sub Form_Resize()
Dim i As Integer
i= AlphaRatio(Me.Height,放最大值)
SetLayeredWindowAttributes Me.hWnd, 0, i,LWA_ALPHA
End Sub

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 WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd