注册 登录
编程论坛 VB6论坛

谁会靠边隐藏

a1919735905 发布于 2016-04-13 19:54, 2497 次点击
就像qq一样,靠边隐藏,哪位大神知道怎么弄
6 回复
#2
yangfrancis2016-04-13 21:59
Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim pt As POINTAPI

Private Sub Form_Load()
Form1.Left = 10: Form1.Top = 10
End Sub

Private Sub Timer1_Timer()
GetCursorPos pt
Label1.Caption = Str(pt.x) + "/" + Str(pt.y)
If pt.x > Form1.Left + Form1.ScaleWidth Or pt.y > Form1.Top + Form1.ScaleHeight Then
   Form1.Hide
Else
   If pt.x < 10 Or pt.y < Form1.Height Then
      Form1.Show
   End If
End If
End Sub
#3
xiangyue05102016-04-13 22:13
对的,同意二楼。关键就是GetCursorPos 判断鼠标位置,然后改变窗体的大小或者显示
#4
a19197359052016-04-14 18:23
回复 2楼 yangfrancis
代码输入在那个控件里
#5
yangfrancis2016-04-14 23:21
Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim pt As POINTAPI
'以上代码是在通用里,以下代码不是已经标明了吗,由空行处分开,分别在Form1,Timer1里
Private Sub Form_Load()
Form1.Left = 10: Form1.Top = 10
End Sub

Private Sub Timer1_Timer()
GetCursorPos pt
Label1.Caption = Str(pt.x) + "/" + Str(pt.y)
If pt.x > Form1.Left + Form1.ScaleWidth Or pt.y > Form1.Top + Form1.ScaleHeight Then
   Form1.Hide
Else
   If pt.x < 10 Or pt.y < Form1.Height Then
      Form1.Show
   End If
End If
End Sub
#6
a19197359052016-04-15 00:07
回复 5楼 yangfrancis
没用点全编译执行只是靠在左上角没有隐藏
#7
pengzhanggui2016-05-09 14:42
好思路
1