先在ListView等控件的角落里放一个PictureBox(放上一个 看起来可以拖的图片) 做为锚点 把MousePointer 属性设置为8然后 Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim lngWidth As Long, lngHeight As Long lngWidth = Picture1.Left + X - Text1.Left lngHeight = Picture1.Top + Y - Text1.Top If lngWidth <= 0 Then lngWidth = 100 If lngHeight <= 0 Then lngHeight = 100 Text1.Width = lngWidth Text1.Height = lngHeight Picture1.Left = Text1.Left + Text1.Width Picture1.Top = Text1.Top + Text1.Height End Sub
form_resize事件里写一个就行了
试一试:Dim x1 As Single Dim y1 As SinglePrivate Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim x2 As Integer Dim y2 As Integer
x2 = x - x1 y2 = y - y1 TreeView1.Width = x2 + TreeView1.Width TreeView1.Height = y2 + TreeView1.Height End SubPrivate Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) x1 = x y1 = y End Sub
把MousePointer 属性设置为8然后
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngWidth As Long, lngHeight As Long
lngWidth = Picture1.Left + X - Text1.Left
lngHeight = Picture1.Top + Y - Text1.Top
If lngWidth <= 0 Then lngWidth = 100
If lngHeight <= 0 Then lngHeight = 100
Text1.Width = lngWidth
Text1.Height = lngHeight
Picture1.Left = Text1.Left + Text1.Width
Picture1.Top = Text1.Top + Text1.Height
End Sub
Dim y1 As SinglePrivate Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim x2 As Integer
Dim y2 As Integer
x2 = x - x1
y2 = y - y1
TreeView1.Width = x2 + TreeView1.Width
TreeView1.Height = y2 + TreeView1.Height
End SubPrivate Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
x1 = x
y1 = y
End Sub