加上这句(SetWindowLong hwnd, (-20), &H80000)运行后窗体就会不见。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 HWND_TOPMOST& = -1
Private Const SWP_NOSIZE& = &H1
Private Const SWP_NOMOVE& = &H2 '置顶
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 GetCursorPos Lib "user32 " (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim screen As POINTAPI '屏幕坐标
Private Sub Form_DblClick()
End
End Sub
Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '置顶
SetWindowLong hwnd, (-20), &H80000 '加上这句,运行后窗体就会不见
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Timer1_Timer()
GetCursorPos screen '屏幕坐标
If screen.X >= Me.Left / 15 And screen.X <= (Me.Left + Me.Width) / 15 And screen.Y >= Me.Top / 15 And screen.Y <= (Me.Top + Me.Height) / 15 Then
SetLayeredWindowAttributes Me.hwnd, vbBlack, 50, 2
Else
SetLayeredWindowAttributes Me.hwnd, vbBlack, 50, 1
End If
End Sub
Private Const HWND_TOPMOST& = -1
Private Const SWP_NOSIZE& = &H1
Private Const SWP_NOMOVE& = &H2 '置顶
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 GetCursorPos Lib "user32 " (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim screen As POINTAPI '屏幕坐标
Private Sub Form_DblClick()
End
End Sub
Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '置顶
SetWindowLong hwnd, (-20), &H80000 '加上这句,运行后窗体就会不见
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Timer1_Timer()
GetCursorPos screen '屏幕坐标
If screen.X >= Me.Left / 15 And screen.X <= (Me.Left + Me.Width) / 15 And screen.Y >= Me.Top / 15 And screen.Y <= (Me.Top + Me.Height) / 15 Then
SetLayeredWindowAttributes Me.hwnd, vbBlack, 50, 2
Else
SetLayeredWindowAttributes Me.hwnd, vbBlack, 50, 1
End If
End Sub