永发信息网

如何用VB6制作QQ的伸缩功能

答案:3  悬赏:40  手机版
解决时间 2021-04-27 13:20
  • 提问者网友:嗝是迷路的屁
  • 2021-04-26 13:21
QQ只要一放到屏幕边上,就能缩进去。鼠标一划过就伸出来。怎么用VB6制作。
最佳答案
  • 五星知识达人网友:三千妖杀
  • 2021-04-26 14:45

窗体加一个timer 不需要设置 以下是窗体代码 很久前写的 比较乱,拿去吧,不要笑哦



Option Explicit


Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXFRAME = 32
Private Const SM_CYFRAME = 33
Private Const SM_CYCAPTION = 4


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


Const INDENTTIME = 150
Const INDENTEDGE = 75


Dim oldX As Single
Dim oldY As Single
Dim IndentDirection As Long
Dim Outing As Boolean
Dim Indenting As Boolean
Dim IndentStep As Long
Dim IndentStepCount As Long


Private Sub Form_Load()
Timer1.Interval = 10
IndentStepCount = INDENTTIME / 10
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Indenting = False
End Sub


Private Sub Timer1_Timer()
Dim MouseIn As Boolean
Dim IndentOver As Boolean
Dim OutOver As Boolean
Dim pt As POINTAPI

If Me.WindowState <> 0 Then Exit Sub
IndentOver = False
OutOver = False
GetCursorPos pt
ScreenToClient Me.hwnd, pt
MouseIn = False
pt.x = pt.x + GetSystemMetrics(SM_CXFRAME)
pt.y = pt.y + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME)
If pt.x * 15 >= 0 And pt.x * 15 <= Me.Width And pt.y * 15 >= 0 And pt.y * 15 <= Me.Height Then
MouseIn = True
End If
If Indenting Or Outing Then
If MouseIn Then
Indenting = False
Outing = True
Else
Outing = False
Indenting = True
End If
If IndentStep >= IndentStepCount Then
IndentOver = True
ElseIf IndentStep < 0 Then
OutOver = True
End If
Select Case IndentDirection
Case 1 '左缩
If Not IndentOver And Not OutOver Then
Me.Left = -Me.Width * (IndentStep / IndentStepCount)
ElseIf IndentOver Then
Me.Left = INDENTEDGE / 2 - Me.Width
ElseIf OutOver Then
Me.Left = 0
End If
Case 2 '上缩
If Not IndentOver And Not OutOver Then
Me.Top = -Me.Height * (IndentStep / IndentStepCount)
ElseIf IndentOver Then
Me.Top = INDENTEDGE / 2 - Me.Height
ElseIf OutOver Then
Me.Top = 0
End If
Case 3 '右缩
If Not IndentOver And Not OutOver Then
Me.Left = Screen.Width - Me.Width + Me.Width * (IndentStep / IndentStepCount)
ElseIf IndentOver Then
Me.Left = Screen.Width - INDENTEDGE / 2
ElseIf OutOver Then
Me.Left = Screen.Width - Me.Width
End If
'Case 4 '下缩
' If Not IndentOver And Not OutOver Then
' Me.Top = Screen.Height - -Me.Height + Me.Height * (IndentStep / IndentStepCount)
' ElseIf IndentOver Then
' Me.Top = Screen.Height - INDENTEDGE / 2
' ElseIf OutOver Then
' Me.Top = Screen.Height - Me.Height
' End If
End Select
If OutOver Then
Outing = False
ElseIf IndentOver Then
Indenting = False
End If
If Outing Then
IndentStep = IndentStep - 1
ElseIf Indenting Then
IndentStep = IndentStep + 1
End If
oldX = Me.Left
oldY = Me.Top
Else
If oldX <> Me.Left Or oldY <> Me.Top Then
If Me.Left < 0 Then Me.Left = 0
If Me.Top < 0 Then Me.Top = 0
If Screen.Width - (Me.Left + Me.Width) < 0 Then Me.Left = Screen.Width - Me.Width
If Screen.Height - (Me.Top + Me.Height) < 0 Then Me.Top = Screen.Height - Me.Height
oldX = Me.Left
oldY = Me.Top
End If
If Me.Left < 0 Or Me.Left < 0 Or Me.Top < 0 Or Screen.Width - (Me.Left + Me.Width) < 0 Or Screen.Height - (Me.Top + Me.Height) < 0 Then
IndentOver = True
Else
OutOver = True
End If
If MouseIn Then
If Not OutOver Then
Outing = True
'BringWindowToTop Me.hwnd
'SetForegroundWindow Me.hwnd
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE
SetWindowPos Me.hwnd, -2, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE
End If
Indenting = False
Else
If Not IndentOver Then Indenting = True
Outing = False
End If
If Me.Left < INDENTEDGE Then '左缩
IndentDirection = 1
IndentStep = (-Me.Left / Me.Width) * IndentStepCount
ElseIf Me.Top < INDENTEDGE Then '上缩
IndentDirection = 2
IndentStep = (-Me.Top / Me.Height) * IndentStepCount
ElseIf Screen.Width - (Me.Left + Me.Width) < INDENTEDGE Then '右缩
IndentDirection = 3
IndentStep = (Me.Left - Screen.Width + Me.Width) / Me.Width * IndentStepCount
'ElseIf Screen.Height - (Me.Top + Me.Height) < INDENTEDGE Then '下缩
' IndentDirection = 4
' IndentStep = (Me.Top - Screen.Height + Me.Height) / Me.Height * IndentStepCount
Else
Indenting = False
Outing = False
End If
End If
'If Indenting Then Debug.Print "Indenting"
'If Outing Then Debug.Print "Outing"
End Sub


全部回答
  • 1楼网友:有你哪都是故乡
  • 2021-04-26 16:07
这个应该是用到系统的鼠标钩子来实现,获取鼠标的屏幕坐标,窗体的伸缩就好办了,请参考: http://hi.baidu.com/ok100fen/blog/item/f42ff5aec0ebd8cb7cd92a3d.html
  • 2楼网友:罪歌
  • 2021-04-26 14:58

方法是做两个窗口,一个是QQ默认的窗口,一个是隐藏窗口(窗口大小很小),判断QQ默认窗口的Y坐标小于一定值的时候(算是在屏幕边),默认窗口显示设置为FALSE,隐藏窗口显示设置为TRUE,并在默认位置显示出来。默认窗口显示就是,当鼠标在隐藏窗口上的时候,就显示默认窗口出来

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯