怎样取消拖放模式

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

已经能实现拖放,也能实现改变大小,但有个问题,实现拖放之后,就不能实现改变大小了,程序一直还处于拖放模式,怎样取消这个模式呢,让它改变大小
...全文
67 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
VB基础类
创建于2007-09-28

7489

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2004-02-16 03:27
社区公告
暂无公告