Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click and Drag problems

Status
Not open for further replies.

goatsaregreat

Programmer
Mar 21, 2001
82
GB
I have figured out a method to click and drag a circle on a form, but the problem is... When I run the program and click and drag to create a circle, the circle is smaller than where I dragged. I know this because after I have one circle on the form, I postion the mouse right on the edge of the already mad circle and draw a new one. If I keep the circle relatively small, it works OK, but if I get any size to it, the circle is smaller than what I tried to create. The larger I try to make the circle, the smaller it gets. It seems to be a relative thing. I'll post my code so you guys can inspect. Please let me know what you think, and feel free to test my code. I wish you would. :)


Public xer As Integer
Public yer As Integer


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xer = X
yer = Y
End Sub


Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xcord As Integer
Dim ycord As Integer
Dim radius As Integer

xcord = ((X + xer) / 2)
ycord = ((Y + yer) / 2)
radius = Abs(X - xcord)
Circle (xcord, ycord), radius

End Sub
 
Hi,

thge distance between 2 points (e.i. your radius) in a coordinate system is:
sqr((x2-x1)^2 +(y2-y1)^2)
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Just for my tuppence, are you dragging the second circle from the circle line itself or from the bounding edge of the original? Remember, the circle you create's size is determined by the bounding box you've dragged.

If you look carefully at the cirlce as you create it, you'll see that the circle's line is not where you clicked and released, but contained within an imaginary square that measures the co-ords edges.

I've not exactly used plain English here, but I think you'll get my point.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top