怎样取消拖放模式

joy8223 2004-02-16 03:27:33
我想对form上的一个控件进行拖放,
Private Sub yard_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

DragX = X
DragY = Y
If Not bSelected Then
yard(Index).Drag vbBeginDrag
End If
End Sub

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)

Source.Drag vbEndDrag
Source.Move X - DragX, Y - DragY

End Sub
这样就可以拖放,但我想在form上改变控件大小
Private Sub yard_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Pnt As POINTAPI
Dim CurX As Long
Dim CurY As Long
Dim DistX As Long
Dim DistY As Long

Const mDist = 150 '注释:150 twips

GetCursorPos Pnt
'注释:Get mouse position
ScreenToClient Me.hwnd, Pnt
'注释:Convert to client coordinate
CurX = Pnt.X * Screen.TwipsPerPixelX
'注释:Pixels to Twips
CurY = Pnt.Y * Screen.TwipsPerPixelY
DistX = Abs(CurX - (yard(Index).Left + yard(Index).Width))
'注释:distance to yard(index)注释:s
DistY = Abs(CurY - (yard(Index).Top + yard(Index).Height))

If DistX <= mDist And DistY <= mDist Then
'注释:set mouse pointer
'注释:according to distance
DesignForm.MousePointer = vbSizeNWSE
ElseIf DistX <= mDist And DistY > mDist Then
DesignForm.MousePointer = vbSizeWE
ElseIf DistX > mDist And DistY <= mDist Then
DesignForm.MousePointer = vbSizeNS
Else
DesignForm.MousePointer = vbDefault
End If

If Button <> 1 Then Exit Sub
If DesignForm.MousePointer = vbSizeNWSE Then
'注释: Change yard(index)注释: Size
yard(Index).Width = CurX - yard(Index).Left
yard(Index).Height = CurY - yard(Index).Top
End If
If DesignForm.MousePointer = vbSizeWE Then
yard(Index).Width = CurX - yard(Index).Left
End If
If DesignForm.MousePointer = vbSizeNS Then
yard(Index).Height = CurY - yard(Index).Top
End If
End Sub

已经能实现拖放,也能实现改变大小,但有个问题,实现拖放之后,就不能实现改变大小了,程序一直还处于拖放模式,怎样取消这个模式呢,让它改变大小
...全文
101 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧