|
-
Jul 27th, 2000, 08:30 PM
#1
Thread Starter
New Member
How can I make click event to Line control on runtime?
I want to make simple cad
please!!! hurry
[Edited by holdu on 07-27-2000 at 10:14 PM]
-
Jul 28th, 2000, 05:10 AM
#2
Fanatic Member
No API needed
[/code]
Private MouseX as Integer
Private MouseY as Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static LineBeingDrawn as Boolean
LineBeingDrawn = Not(LineBeingDrawn)
If LineBeingDrawn Then
MouseX = X
MouseY = Y
Else:
Form1.Line(MouseX, MouseY)-(X, Y)
End If
End Sub
[/code]
Hope it works!
Thank you for listening,
Me
-
Aug 1st, 2000, 10:54 PM
#3
Thread Starter
New Member
Re: No API needed
That is just make line.
I want click event on line like to cad program.
please help me
I don't care hard work...
-
Aug 2nd, 2000, 04:22 AM
#4
Fanatic Member
What exactly do you want?
A line that moves around with the mouse until you click?
I need a little more detail before I can give you the code.
-
Aug 2nd, 2000, 07:42 AM
#5
Hyperactive Member
A line doesn't have a click event. Either draw the line on a control that does have a click (like a picturebox) or use the forms_mousedown event to check where was clicked on the line.
Or create a usercontrol (probably the easiest method) and create your own click event.
-
Aug 2nd, 2000, 07:34 PM
#6
Thread Starter
New Member
Always thanks for your helps.
Now, I need any-control that must have click event.
I want to draw line and then retouch(cut, delete, move, reduce, graw,etc) on runtime, like to cad.
-
Aug 2nd, 2000, 10:30 PM
#7
Not sure if this'll help, but its a cool feature . Kind of like V(ery) Basic's idea.
Code:
'add one line to your form one running the vertical length of your form
'add a second line to your form running the horizontal width of the form
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y
As Single)
Line1.X1 = X
Line1.X2 = X
Line2.Y1 = Y
Line2.Y2 = Y
End Sub
-
Aug 2nd, 2000, 11:29 PM
#8
Thread Starter
New Member
Yes... I know this case.
But, problem is how do computer know click on the Line control. Up-answer is next work(only move. how can we indicate line). When we just click on the Line, we can see any event.
Very hard problem??
Or, cann't solve??
-
Aug 3rd, 2000, 08:15 AM
#9
Fanatic Member
Oh, I get it now.
You want to know when the user clicks on a line. 
There is some very long code to find this, which I made and then deleted a while ago (I'm that kind of irrational, moody person), but why do you need such a function? Other CAD apps don't use one.
If you really need the code I'll be pleased to rewrite it for you.
*wry smile*
Just give the word,
Moi.
-
Aug 3rd, 2000, 08:49 AM
#10
Thread Starter
New Member
Oh... thanks for your kindness
Now, I really need it....
please...
-
Aug 6th, 2000, 08:03 AM
#11
Fanatic Member
Give e-mail address and you'll have it within the Microsoft week.
-
Aug 6th, 2000, 08:12 AM
#12
Monday Morning Lunatic
Don't wait up for it then 
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2000, 03:23 AM
#13
Fanatic Member
Microsoft Week = Anything between a month and a year
(Just joking holdu, you'll get it)
-
Aug 7th, 2000, 07:24 AM
#14
Thread Starter
New Member
Thank you everyone
I got it this problem....
-
Aug 7th, 2000, 12:33 PM
#15
Fanatic Member
Line Control "Click" event
Is it SO difficult to understand the question?
Dear Holdu,
Yes indeed there's absolutely NO way to trigger the Click event for the Line control. BUT: there is an algorithm to create it, for ANY line which start and end coordinates are known.
Have you ever heard of my friend BRESENHAM? (probably dead)
The "Bresenham algorithm" is a standard algorithm to create lines, circles, ... via the setting of dots. So, if you can set the dots, you can also use this algorithm to check out if a mouse click (or even: Move) happened on a line.
Use this algorithm and for every dot drawn (or: calculated, you do not really want to draw it) you check if you Mouse X and Y corresponds with the calculated dot coordinates.
If so, stop the algorithm and simply return with the message that YOU CLICKED ON A DOT!
This algorithm is very fast, in fact, on a Pentium you won't even notice the calculating delay!
So, if you're interested, I can send you this algorithm. It's not big code (just some lines).
Bye,
-
Aug 7th, 2000, 01:35 PM
#16
Fanatic Member
Ermm.
I'm already making the class module for him. I didn't find out about the algorithm, so I made one myself 
It's more of a semi-algorithm, using SetPixel. On my little 200mHZ, 32MB RAM machine, you can't notice the delay at all.
If holdu waits a couple of days and gives me an e-mail address, I can send the whole project to him (with Move, Delete, Grow, Reduce, Rotate etc.)
I'll make it in time, holdu! I've done make line, Move and delete already.
-
Aug 7th, 2000, 07:36 PM
#17
Thread Starter
New Member
Re: Line Control
I found how to solve for this problem. But this way is not easy.
I use line1.x1, x2, y1,y2, and mouse event....
[email protected]
[Edited by holdu on 08-07-2000 at 08:39 PM]
-
Aug 8th, 2000, 08:19 AM
#18
Fanatic Member
Patience, holdu, patience
Arrgggggh!
I'm making a ****ing class ****ing module, so if you'd be patient enough to wait a couple of days I'll give it to you.
Its got Cut, Copy, Delete, Move (which is pretty ****ing cool at the moment), Enlarge and Reduce. So if you just wait and give me your e-mail address I'll send it to you. Its taken me a while, so it's probably got more features than yours.
Just take a look bu giving me your ****ing e-mail!
-
Sep 24th, 2000, 05:25 AM
#19
New Member
Am I too late!? (Wait for me!)
Sup guys,
I've read the thread and im on the same boat as Holdu. Im working on a math/CAD-like proggy that will allow the user to draw poly shapes. The proggy would then, based on the drawn shape(s), spit out missing sides and/or angles, vector additions, areas, etc. The 'math' part, you can say that i got a pretty good handle on it, and that which i dont know i can easily learn from my Physics/Math courses/books. What i do need to know is, how to manipulate lines, ultimately to allow the users to re-define their 'shapes'. So far i've given the user the ability to make lines by manipulating a LINE CONTROL. I then use the LINE CONTROL's properties to create a LINE METHOD on the form(which can also be a picturebox). Wow they can make lines! Thats all fine n dandy but the hard part is trying to manipulate those LINE METHODS.
As an example: The user will create a triangle with three lines (what were you expecting, 5 lines?). He will specify one angle on it and, maybe, the length to 2 legs. The program would then calculate the other 2 angles and missing length. But, now he wants to c how the calculations will turn out if the degree of the given angle is, say, 5 greater. He would need to click on the corresponding angle and change it (by drag or pull). So, he needs to be able to manipulate the triangle to recalculate for the same shape but different size.
Did that make sense? No? ...too bad j/k If u want me to explain more let me know, but BASICALLY what im after is the code your writing for Holdu. So, if u can plz help out a poor VB soul 
PS: [email protected]
- Evol
-
Sep 24th, 2000, 06:33 AM
#20
Fanatic Member
The code I wrote for holdu needs VB6 and it's essentially what the line control looks like at design-time at runtime (hard to understand )
I'll send it to you, but I'm not sure it's what you want.
-
Sep 24th, 2000, 07:02 PM
#21
Thread Starter
New Member
Re: Am I too late!? (Wait for me!)
I can't english very well. so I afraid that you don't understand my think and I can't unerstand your write..
Uhm... I got cod to V(ery) Basic guy.
That is very usefull. Then I modified for my program.
May be you need V(ery) Basic guy's. If you want it, I will send you..
Of course, V(ery) Basic guy must permit.... you know
-
Sep 25th, 2000, 05:21 PM
#22
New Member
Yup.
lol everyone thinks i dont need this code? y? if anything im probably have more use for it than u guys. (im just saying). ill explain the application one more time.
have u ever had a math class? im assuming 'yes'. Ok, now remember when you had to draw triangels and rectangles, squars... and angels... u had to wip out ur protractor and/or ur ruler right? then u would measure lengths and angels and what not. well my app will do all that on the computer! so instead of putting down ur ruler and drawing a 5 inch line, in my app u will just draw a line and as u drag it its gonna have like a lil tooltip saying what the current lenght of the line being made. so far i can do this, but now the you want to change that 5inch line to, say, 10 inches... instead of clearing the drawing u will b able to drag the line 5 more inches to reach 10 inches... now this drag method (sizing method) is what i need to figure out how to do.
(v)ery your code lets you do this, but im having a hard time figuring it out... its kinda advanced for me, but im going line by line. the specific place where i have trouble is trying to understand event creation... like for the line. ur CLS files define methods and properties and other stuff about the line. this is something new to me.
if u, or u guys, can plz help me understand the subject. this is just to speed things up, w/in time ill figure out the code u sent me. thnx again.
- Evol
-
Sep 26th, 2000, 09:38 AM
#23
Member
Line control
' Paste this code in a VB Form containing a line control ' named Line1
' The Hit routine will calculate the distance from the mouse ' pointer to the line control
Option Explicit
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Hit(Line1, X, Y) Then
MsgBox "HIT"
End If
End Sub
Private Sub Form_Mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Hit Line1, X, Y
End Sub
'
' Hit will return true if (X,Y) is close enough to the line (Distance (X,Y)to line < 20
'
Function Hit(L As Line, X As Single, Y As Single) As Boolean
Dim tx As Single, ty As Single
Static XX As Single, YY As Single
Dim Distance As Single
' Parameterized line
tx = (X - L.X1) / (L.X2 - L.X1)
ty = (Y - L.Y1) / (L.Y2 - L.Y1)
' Reset form and color
Me.Cls
L.BorderColor = RGB(0, 0, 0)
' Inside hit area if 0 <= tx <= 1 and 0 <= ty <= 1
If tx < 0 Or tx > 1 Or ty < 0 Or ty > 1 Then
Else
XX = (X + L.X1 + ty * (L.X2 - L.X1)) / 2
YY = (Y + L.Y1 + tx * (L.Y2 - L.Y1)) / 2
Me.Line (X, Y)-(XX, YY)
Distance = Sqr((X - XX) ^ 2 + (Y - YY) ^ 2)
Hit = (Distance < 20) ' 20 is choosen randomly (smaller number will giver closer hits to the line
If (Distance < 20) Then L.BorderColor = RGB(255, 0, 0)
End If
End Function
-
Sep 30th, 2000, 01:46 PM
#24
Alfred:
Nice code, but if you want to have fun, try a VERTICAL line with your code... 
Sorry 'bout that...
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
|