永发信息网

VB6,如何制作qq的伸缩功能

答案:1  悬赏:0  手机版
解决时间 2021-06-05 09:17
VB6,如何制作qq的伸缩功能
最佳答案

窗体加一个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


我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
初三化学题。急!
qq宠物古堡战记有什么奖励?
魔兽世界人物特色?
为什么大家都喜欢吃土豆呢?
如何把美图秀秀弄的文字放到空间主页
岳阳楼区岳阳物流信息中心地址在什么地方,想
爱一个人到底要怎样爱?
什么牌子的MP5有摄像功能?
这是什么?HEIP!
急求高中必修二单词听力下载地址(好记星V1用
E71在充电的时候怎么没声音
祁东县衡阳容声厨卫电器这个地址怎么能查询到
QQ怎样会过期?
在网上卖保健品赚钱不?
为什么现在手机?进不了百度
推荐资讯
求个可用的暴击去红补丁,不要网址!最好加QQ
胎儿脑集液是怎么回事
宋朝词人分为哪几派?谁为代表?哪些最出名?
未成年人如何存款
我一朋友诊治一个十岁女孩,初步诊断为上感,
请问.冬天了我的手很干燥不知道用什么保养好
有啥好看的笑话?
娄星区娄底舒心堂按摩推拿在什么地方啊,我要
pas模拟器游戏放哪个文件夹?
DNF红丸多少钱啊?
新蔡县驻马店英姿发屋(新蔡县烟草专卖局办证
专业篮筐是什么材料
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?