导航

« 法拉第CSS完美兼容IE6/IE7/FF的通用方法  »

VB窗口实现QQ靠边隐藏效果 分享

Vb6.0

vb要如何实现QQ靠边隐藏效果呢,高手们肯定有许多方法,下面是我收藏整理的代码,其中用了一个计时器(Timer)

声明部分:

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

计时器代码(timer的interval可根据需要设置,我设的是500):

On Error Resume Next
GetCursorPos p
If Me.Top <= 0 Then   '位于屏幕顶部时
   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
     Me.Top = 0 - Me.Height + 50
   End If
   If p.x > Me.Left / 15 And p.x < Me.Left / 15 + Me.Width / 15 And p.y < 3 Then
     Me.Top = 0
   End If
End If

If Me.Left <= 0 Then '位于屏幕左边时
   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
     Me.Left = 0 - Me.Width + 50

   End If
   If p.x < 3 And p.y > Me.Top / 15 And p.y < Me.Height / 15 + Me.Top / 15 Then
     Me.Left = 0
   End If
End If

If Me.Left >= Screen.Width - Me.Width Then   '位于屏幕右边

   If p.y > Me.Height / 15 + Me.Top / 15 Or p.y < Me.Top / 15 Or p.x < Me.Left / 15 Then
     Me.Left = Screen.Width - 50

   End If
   If p.x > Screen.Width / 15 - 3 And p.y > Me.Top / 15 And p.y < Me.Height / 15 + Me.Top / 15 Then
     Me.Left = Screen.Width - Me.Width
   End If
End If

If Me.Top >= Screen.Height - Me.Height Then  '位于屏幕底部时,底部可省
   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
     Me.Top = Screen.Height + 50
   End If
   If p.x > Me.Left / 15 And p.x < Me.Left / 15 + Me.Width / 15 And p.y > Screen.Height / 15 - 3 Then
     Me.Top = Screen.Height - Me.Height
   End If
End If

 

效果:http://www.spersky.com/post/61.html

  • 顶一下

落日故乡推荐
-->

原创文章如转载,请注明:转载自落日故乡

本文链接地址:http://www.spersky.com/post/64.html

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

内容搜索


常用链接

最新评论及回复

Powered By Z-Blog

Copyright spersky All Rights Reserved.Theme Moonlight,Calf modified.