VB实现类似QQ的吸附屏幕的功能

页面导航:首页 > 软件编程 > vb.net > VB实现类似QQ的吸附屏幕的功能

VB实现类似QQ的吸附屏幕的功能

来源: 作者: 时间:2016-01-21 10:23 【

建立新的form,加入一个timer,interval设为100Option Explicit Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI X As Long Y As Long End Type Dim p As POINTAPI Priv

建立新的form,加入一个timer,interval设为100

Option Explicit

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim p As POINTAPI

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 S_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE 加载窗口是指定窗口在最顶层
Timer1.Enabled = True
End Sub


Private Sub Timer1_Timer()
On Error Resume Next
GetCursorPos p
If Me.Top <= 0 Then form1 is not hide and form1s top is 0
hide form
If p.Y > Me.Height / 15 + Me.Top / 15 Or p.X > Me.Width / 15 + Me.Left / 15 Or p.X < Me.Left / 15 Then mouse is not over form1
Me.Top = 0 - Me.Height + 50
End If
show form
If p.X > Me.Left / 15 And p.X < Me.Left / 15 + Me.Width / 15 And p.Y < 3 Then mouse is over form
Me.Top = 0
End If
End If

If Me.Left <= 0 Then form1 is not hide form1s left is 0
hide form
If p.Y > Me.Height / 15 + Me.Top / 15 Or p.Y < Me.Top / 15 Or p.X > Me.Width / 15 + Me.Left / 15 Then mouse is not over form1
Me.Left = 0 - Me.Width + 50

End If
show form
If p.X < 3 And p.Y > Me.Top / 15 And p.Y < Me.Height / 15 + Me.Top / 15 Then mouse is over form
Me.Left = 0
End If
End If

If Me.Left >= Screen.Width - Me.Width Then
hide form

If p.Y > Me.Height / 15 + Me.Top / 15 Or p.Y < Me.Top / 15 Or p.X < Me.Left / 15 Then mouse is not over form1
Me.Left = Screen.Width - 50

End If
show form
If p.X > Screen.Width / 15 - 3 And p.Y > Me.Top / 15 And p.Y < Me.Height / 15 + Me.Top / 15 Then mouse is over form
Me.Left = Screen.Width - Me.Width
End If
End If

End Sub

Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <