我想在鼠标拖动改变控件的大小(windows资源管理器的效果)

解决方案 »

  1.   

    '==================================================
    '运行环境下,改变控件大小的代码(只是一个方向的示例)
    '==================================================Public bX, bY As Long
    Public bW, bH As LongPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.MousePointer = 0
    End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 And Me.MousePointer = 8 Then
       bX = X
       bY = Y
       bW = Picture1.Width
       bH = Picture1.Height
    End If
    End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 0 Then
       If X > Picture1.Width - 150 And X < Picture1.Width + 50 And Y > Picture1.Height - 150 And Y < Picture1.Height + 50 Then
          Me.MousePointer = 8
       Else
          Me.MousePointer = 0
       End If
    ElseIf Button = 1 Then
       If bW + X - bX <= 0 Or bH + Y - bY <= 0 Then Exit Sub
       Picture1.Width = bW + X - bX
       Picture1.Height = bH + Y - bY
    End If
    End Sub