In a picturebox I have this rectangular shape control that can be resized when dragging on its sides. The basic core of the code I'm using is,
The problem is, I'm getting somewhat confused about how I should handle the case when you make the size ever smaller and reach 0 so that you must stretch in the opposite direction. I suppose I'll come out with some working code if I rack my brain a little longer but I'd appreciate it if someone had some handy template.Code:Dim DraggingFlag As Boolean Dim X0 As Single, Y0 As Single Private Sub Form_Load() DraggingFlag = False End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) X0 = X Y0 = Y DraggingFlag = True End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim dx As Single, dy As Single 'This is the case for dragging on the right side 'The rest are similar and I don't transbribe them If DraggingFlag Then dx = X - X0 With Shape1 .Move .Left, .Top, .Width + dx End With End If End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) DraggingFlag = False End Sub




Reply With Quote