[原创]浮动窗体

作者在 2007-04-23 01:32:00 发布以下内容

 

Option Explicit
Private Declare GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare GetParent Lib "user32" (ByVal hwnd As Long) As Long

Private Type POINTAPI
    x As Long
    y As Long
End Type


Private Sub Form_Load()
   Me.Left = -Me.Width + 15
End Sub

Private Sub Timer1_Timer()
    Dim i As Long
    Dim iPos As POINTAPI
    Dim pace As Long

   
    GetCursorPos iPos '获得当前鼠标位置
   
    i = WindowFromPoint(iPos.x, iPos.y) '获得当前鼠标位置的句柄
   
    If i = Me.hwnd Or GetParent(i) = hwnd Or GetParent(GetParent(i)) = hwnd Then
    
       While Me.Left <= 0
          Me.Left = Me.Left + 1
          DoEvents
       Wend
   
    Else
        While Me.Left >= -Me.Width + 15
           Me.Left = Me.Left - 1
           DoEvents
        Wend
    End If
End Sub

 

 

默认分类 | 阅读 1931 次
文章评论,共0条
游客请输入验证码
浏览585038次