trasher
October 4th, 2001, 01:07 PM
I want to add in my program a selecting square area (like in paint or in vb when you want to select multiples controls at the same time). How can I do that ???
thanks for help
Make it with rocker style \w/
DSJ
October 4th, 2001, 01:57 PM
Put a Shape control on Form1 and try this code:
option Explicit
Dim sTopStart as Single
Dim sLeftStart as Single
private Sub Form_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
If Button = vbLeftButton then
Shape1.Top = Y
Shape1.Left = X
sTopStart = Y
sLeftStart = X
Shape1.Height = 0
Shape1.Width = 0
Shape1.Visible = true
End If
End Sub
private Sub Form_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
If Button = vbLeftButton then
If Y > sTopStart then
Shape1.Height = Y - sTopStart
else
Shape1.Top = Y
Shape1.Height = sTopStart - Y
End If
If X > sLeftStart then
Shape1.Width = X - sLeftStart
else
Shape1.Left = X
Shape1.Width = sLeftStart - X
End If
End If
End Sub
private Sub Form_MouseUp(Button as Integer, Shift as Integer, X as Single, Y as Single)
Shape1.Visible = false
MsgBox "Whever code to process selection..."
End Sub