|
-
May 18th, 2001, 03:34 AM
#1
Thread Starter
Hyperactive Member
Selection Box
How do I make a selection box disapear?
-
May 18th, 2001, 03:50 AM
#2
Retired VBF Adm1nistrator
...
Code:
NameOfControl.Visible = False
?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
May 18th, 2001, 04:04 AM
#3
Thread Starter
Hyperactive Member
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
'??????????????? QUESTION LIES HERE ?????????????????
' I here have to erase the previous rectangle without
' removing any thing on the form.
' And Then,
' Draw a rectangle From (fpx, fpy) to (x,y)
End If
End Sub
Thanks
-
May 18th, 2001, 11:40 AM
#4
Code:
Form_mousedown(...)
FIsavepicturetosomewhere...
isselecting...
end
Form_mouseup(...)
FISelect(...)
FIBlitsavedpicture...
end
Hope you understand all of that.
Z.
-
May 20th, 2001, 06:35 AM
#5
Thread Starter
Hyperactive Member
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.
-
May 20th, 2001, 11:18 AM
#6
Frenzied Member
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).
Code:
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
There you have! Trust me, it works 
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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|