:confused: How do I make a selection box disapear?
Printable View
:confused: How do I make a selection box disapear?
...
?Code:NameOfControl.Visible = False
Maybe I mis-explained, what the problem is.
I'm trying to draw a selection box, here's how:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
fpx = x
fpy = y
isSelecting = true
end sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If isSelecting = True Then
:confused: :confused: :confused:
'??????????????? QUESTION LIES HERE ?????????????????
' I here have to erase the previous rectangle without
' removing any thing on the form.
:confused: :confused: :confused:
' And Then,
' Draw a rectangle From (fpx, fpy) to (x,y)
End If
End Sub
Thanks
Hope you understand all of that.Code:Form_mousedown(...)
FIsavepicturetosomewhere...
isselecting...
end
Form_mouseup(...)
FISelect(...)
FIBlitsavedpicture...
end
Z.
Hi there,
Thank you for you help.
But I don't think this will do the job. Because between the MouseDown, and the MouseUp events, there is the MouseMove, during which I'm drawing the new line, and Intend to remove the old one.
Do you think I have to blt the image on each mouse move occurence?
Thank you.
Here's how I did it in my map editor. NOTE: The key to it is that you use BitBlt to draw a rectangle that inverts the colors behind it wherever I say "Draw rectangle ..." (by using vbSrcNot I think).
There you have! Trust me, it works :pCode:
Dim Selecting As Boolean
Dim SelectX As Long, SelectY As Long
Dim OldMouseX As Long, OldMouseY As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Selecting = True
SelectX = X
SelectY = Y
OldMouseX = X
OldMouseY = Y
'Draw a rectangle from [SelectX,SelectY] to [OldMouseX,OldMouseY] (the new selection)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Selecting Then
'Draw a rectangle from [SelectX,SelectY] to [OldMouseX,OldMouseY]. This will erase the previous one, because inverting an inverted rectangle will restore it!
OldMouseX = X
OldMouseY = Y
'Draw a rectangle from [SelectX,SelectY] to [OldMouseX,OldMouseY] (the new selection)
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Selecting = False
End Sub
You have 2 ways of doing this: you can manually draw a rectangle, by drawing 4 lines around it; or draw a rectangle covering it all and then drawing another one inside it, 1 pixel smaller, like this:
BitBlt from [SelectX, SelectY] to [OldMouseX, OldMouseY]
BitBlt from [SelectX+1, SelectY+1] to [OldMouseX-1, OldMouseY-1]