老老年写的一个东西 原理好像都时这个样子 Private Sub Timer2_Timer() Dim lpPoint As POINTAPI GetCursorPos lpPoint If lpPoint.Y < 15 And (lpPoint.X < (Me.Left / 15 + Me.Width / 15) And lpPoint.X > Me.Left / 15) Then '15为之间的一个转换 Me.Visible = True SetForegroundWindow Me.hwnd myval = SetWindowPos(主窗体.hwnd, -1, 0, 0, 0, 0, 3) ElseIf lpPoint.Y > Me.Height / 15 Or lpPoint.X < Me.Left / 15 Or lpPoint.X > (Me.Left / 15 + Me.Width / 15) Then Me.Visible = False End If End SubPrivate Sub move_Click() Call Shell_NotifyIcon(NIM_DELETE, nfIconData) End SubPrivate Sub Timer3_Timer() Static nb Timer2.Enabled = False Me.Visible = True nb = nb + 1 If nb = 10 Then Timer3.Enabled = False Timer2.Enabled = True End If End SubPrivate Sub Timer4_Timer() Dim lpPoint As POINTAPI If Timer3.Enabled = False Then If GetAsyncKeyState(VK_L) < 0 Then If Me.Visible = True Then Timer2.Enabled = False If (lpPoint.X < (Me.Left / 15 + Me.Width / 15) And lpPoint.X > Me.Left / 15) Then Timer2.Enabled = False Else Timer2.Enabled = True End If End If End If If Me.Top > 15 And Me.Visible = True Then '15为之间的一个转换 Timer2.Enabled = False Else Timer2.Enabled = True End If End IfEnd Sub
Private Declare Function GetCursorPos _ Lib "user32" (lpPoint As POINTAPI) As LongPrivate Type POINTAPI X As Long Y As Long End Type
Option Explicit Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Type POINTAPI X As Long Y As Long End Type Dim Mouse As POINTAPIPrivate Sub Timer1_Timer() On Error Resume Next Dim xnum As Boolean Dim ynum As Boolean xnum = True ynum = True GetCursorPos Mouse If Mouse.X < Me.Left / 15 Or Mouse.X > Me.Left / 15 + Me.Width / 15 Then xnum = False If Mouse.Y < Me.Top / 15 Or Mouse.Y > Me.Top / 15 + Me.Height / 15 Then ynum = False If Me.Left < 150 And Me.Height > 400 Then '左 If xnum = False Or ynum = False Then Me.Left = 0 - Me.Width + 50 Exit Sub Else Me.Left = 0 End If End If If Me.Left > Screen.Width - Me.Width - 150 And Me.Height > 400 Then '右 If xnum = False Or ynum = False Then Me.Left = Screen.Width - 50 Exit Sub Else Me.Left = Screen.Width - Me.Width End If End If If Me.Top < 150 And Me.Height > 400 Then '上 If xnum = False Or ynum = False Then Me.Top = 0 - Me.Height + 50 Exit Sub Else Me.Top = 0 End If End If End Sub直接放到窗体上把timer控件时间设置一下就可以用了
Private Sub Timer2_Timer()
Dim lpPoint As POINTAPI
GetCursorPos lpPoint
If lpPoint.Y < 15 And (lpPoint.X < (Me.Left / 15 + Me.Width / 15) And lpPoint.X > Me.Left / 15) Then '15为之间的一个转换
Me.Visible = True
SetForegroundWindow Me.hwnd
myval = SetWindowPos(主窗体.hwnd, -1, 0, 0, 0, 0, 3)
ElseIf lpPoint.Y > Me.Height / 15 Or lpPoint.X < Me.Left / 15 Or lpPoint.X > (Me.Left / 15 + Me.Width / 15) Then
Me.Visible = False
End If
End SubPrivate Sub move_Click()
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End SubPrivate Sub Timer3_Timer()
Static nb
Timer2.Enabled = False
Me.Visible = True
nb = nb + 1
If nb = 10 Then
Timer3.Enabled = False
Timer2.Enabled = True
End If
End SubPrivate Sub Timer4_Timer()
Dim lpPoint As POINTAPI
If Timer3.Enabled = False Then If GetAsyncKeyState(VK_L) < 0 Then
If Me.Visible = True Then
Timer2.Enabled = False
If (lpPoint.X < (Me.Left / 15 + Me.Width / 15) And lpPoint.X > Me.Left / 15) Then
Timer2.Enabled = False
Else
Timer2.Enabled = True
End If
End If
End If If Me.Top > 15 And Me.Visible = True Then '15为之间的一个转换 Timer2.Enabled = False
Else
Timer2.Enabled = True
End If
End IfEnd Sub
Lib "user32" (lpPoint As POINTAPI) As LongPrivate Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Type POINTAPI
X As Long
Y As Long
End Type
Dim Mouse As POINTAPIPrivate Sub Timer1_Timer()
On Error Resume Next
Dim xnum As Boolean
Dim ynum As Boolean
xnum = True
ynum = True
GetCursorPos Mouse
If Mouse.X < Me.Left / 15 Or Mouse.X > Me.Left / 15 + Me.Width / 15 Then xnum = False
If Mouse.Y < Me.Top / 15 Or Mouse.Y > Me.Top / 15 + Me.Height / 15 Then ynum = False
If Me.Left < 150 And Me.Height > 400 Then '左
If xnum = False Or ynum = False Then
Me.Left = 0 - Me.Width + 50
Exit Sub
Else
Me.Left = 0
End If
End If
If Me.Left > Screen.Width - Me.Width - 150 And Me.Height > 400 Then '右
If xnum = False Or ynum = False Then
Me.Left = Screen.Width - 50
Exit Sub
Else
Me.Left = Screen.Width - Me.Width
End If
End If
If Me.Top < 150 And Me.Height > 400 Then '上
If xnum = False Or ynum = False Then
Me.Top = 0 - Me.Height + 50
Exit Sub
Else
Me.Top = 0
End If
End If
End Sub直接放到窗体上把timer控件时间设置一下就可以用了