# Re: 如何让USER自行拖曳放大缩小TextBox?

Posted by Honey on August 23, 1998 at 00:19:18:

In Reply to: 如何让USER自行拖曳放大缩小TextBox? posted by Richard on August 21, 1998 at 13:17:37:

: 请教各位前辈:
: Form大小可由User拖曳控制请教Form里的TextBox如何也让User自行拖曳控制?

我把以前写过的拿出来给你参考一下下
有些部分还是得靠你自己修改喔
原理其实很简单啦 希望你能看的懂

表单(Form1)上有一个Text1

'以下从一般宣告开始
Dim gx As Single
Dim gy As Single
Dim Jx As Single
Dim Jy As Single
Dim J, K
Dim S, D
Option Explicit

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Jx = X
Jy = Y
J = Text1.Width
K = Text1.Height
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
S = Text1.Left + Text1.Width
D = Text1.Top + Text1.Height
On Error GoTo FINISH
If X > S - 50 And X < S + 50 Then
Form1.MousePointer = 9 '东西指向
End If
If Y > D - 50 And Y < D + 50 Then
Form1.MousePointer = 7 '南北指向
End If
If Y > D And Y < D + 40 _
And X > D And X < D + 40 Then
Form1.MousePointer = 8'西北东南指向
End If
If Button = 1 And Not Form1.MousePointer = 0 Then
If Form1.MousePointer = 8 Then
Text1.Width = J - Jx + X
Text1.Height = K - Jy + Y
End If
If Form1.MousePointer = 7 Then
Text1.Height = K - Jy + Y
End If
If Form1.MousePointer = 9 Then
Text1.Width = J - Jx + X
End If
End If
FINISH:

End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
gx = X
gy = Y
J = Text1.Width
K = Text1.Height
Text1.MousePointer = 5
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
S = Text1.Left + Text1.Width
D = Text1.Top + Text1.Height
If Y > D And Y < D + 40 _
And X > D And X < D + 40 Then
Form1.MousePointer = 8
End If
If Button = 1 Then
Text1.MousePointer = 5
Text1.Left = Text1.Left - gx + X
Text1.Top = Text1.Top - gy + Y
Else
Text1.MousePointer = 0
End If
End Sub

Follow Ups:

- Re: 如何让USER自行拖曳放大缩小TextBox? Richard 13:41:34 8/23/98 (0)