|
Attribute VB_Name = "ModOnTop"
'************************************************* ************************
'**Module name: ModOnTop
'** Explanation: Place the form on the top layer of the Z axis, set the form transparency, whether the mouse can penetrate
'** Creator: Ma Daha
'** Date: December 17, 2003
'**Revised by:
'** Date: November 8, 2006
'**Description: http://www.m5home.com
'**Version: V1.4
'************************************************* ************************
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 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 SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long,
ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const LWA_ALPHA =&H2
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED =&H80000
Private Const WS_EX_TRANSPARENT As Long =&H20&
Private Const SWP_NOSIZE&=&H1
Private Const SWP_NOMOVE&=&H2
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_BROADCAST =&HFFFF&
Private Const HWND_TOP = 0
Public Sub OnTop(ByVal tForm As Form, Optional ByVal Top As Boolean = True, Optional TouMing As Long = 255, Optional cMouse As Boolean = False)
'************************************************* ************************
'**Parameter name: Top
'**Description: Whether to put the form on the top of the Z axis
'**Parameter name: TouMing
'**Description: Window transparency (valid for WIN2000 and above)
'**Parameter name: cMouse
'**Description: whether the mouse can penetrate
'************************************************* ************************
Dim Ret As Long
Ret = GetWindowLong(tForm.hwnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
If cMouse Then Ret = Ret Or WS_EX_TRANSPARENT
SetWindowLong tForm.hwnd, GWL_EXSTYLE, Ret
If TouMing <0 Then TouMing = 0
If TouMing> 255 Then TouMing = 255
SetLayeredWindowAttributes tForm.hwnd, 0, TouMing, LWA_ALPHA
If Top = True Then
SetWindowPos tForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos tForm.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub
**********************************************
This can only make the program translucent, the mouse penetrates, and does not respond to WIN+D
But it is impossible to realize that the playback video is also translucent. Once there is a translucent effect, the video cannot be displayed... |
|