Dim m As Integer Dim a As BooleanPrivate Sub Form_Click() Dim i As Integer a = Not a If a = True Then m = Me.Height For i = m To 100 Step -10 Me.Height = i Next i Else For i = 100 To m Step 10 Me.Height = i Next i End If End Sub
(转载)Option ExplicitPrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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 LongPrivate Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type POINTAPI X As Long Y As Long End TypePrivate Const HWND_TOPMOST = -1 Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 Private Const HWND_TOP = 0 Private Const SWP_NOACTIVATE = &H10 Private Const SWP_SHOWWINDOW = &H40 Private Sub Form_Load() SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE End SubPrivate Sub Timer1_Timer() Dim p As POINTAPI Dim f As RECT GetCursorPos p GetWindowRect Me.hwnd, f If Me.WindowState <> 1 Then If p.X > f.Left And p.X < f.Right And p.Y > f.Top And p.Y < f.Bottom Then If Me.Top < 0 Then Me.Top = -10 Me.Show ElseIf Me.Left < 0 Then Me.Left = -10 Me.Show ElseIf Me.Left + Me.Width >= Screen.Width Then Me.Left = Screen.Width - Me.Width + 10 Me.Show End If
Else If f.Top <= 4 Then Me.Top = 40 - Me.Height ElseIf f.Left <= 4 Then Me.Left = 40 - Me.Width ElseIf Me.Left + Me.Width >= Screen.Width - 4 Then Me.Left = Screen.Width - 40 End If End If End IfEnd Sub
m = Me.Height
For i = m To 0 Step -10
Me.Height = i
Next i
End Sub
试试这个,这个是可以的…
我试过,不闪……
我要的不是你写的这种效果
Dim a As BooleanPrivate Sub Form_Click()
Dim i As Integer
a = Not a
If a = True Then
m = Me.Height
For i = m To 100 Step -10
Me.Height = i
Next i
Else
For i = 100 To m Step 10
Me.Height = i
Next i
End If
End Sub
其实--------------------------------
答案--------------------------------
很简单------------------------------
那就是------------------------------
----------------------------我也不会!
逗你玩!
其实你需要留一小部分窗体在桌面上,然后在用Form_MouseMove弹出窗体
在调用api捕获鼠标坐标来判断是否鼠标移开窗体,随后就是在将窗体移回去!
大量的例子下载
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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 LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End TypePrivate Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOP = 0
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Sub Form_Load() SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End SubPrivate Sub Timer1_Timer()
Dim p As POINTAPI
Dim f As RECT
GetCursorPos p
GetWindowRect Me.hwnd, f
If Me.WindowState <> 1 Then
If p.X > f.Left And p.X < f.Right And p.Y > f.Top And p.Y < f.Bottom Then If Me.Top < 0 Then
Me.Top = -10
Me.Show
ElseIf Me.Left < 0 Then
Me.Left = -10
Me.Show
ElseIf Me.Left + Me.Width >= Screen.Width Then
Me.Left = Screen.Width - Me.Width + 10
Me.Show
End If
Else
If f.Top <= 4 Then
Me.Top = 40 - Me.Height
ElseIf f.Left <= 4 Then
Me.Left = 40 - Me.Width
ElseIf Me.Left + Me.Width >= Screen.Width - 4 Then
Me.Left = Screen.Width - 40
End If
End If
End IfEnd Sub
等待ing......