|
-
Oct 6th, 2007, 09:08 PM
#1
Thread Starter
Junior Member
Draw a line that can have properties
Hi. I need to draw a line or lines and give them later some properties. For example, I would like to draw a line with the cursor, then select the line with the cursor and tell the computer the line has certain length or certain diameter or certain color. It is not necessary for the line to change according to those properties, only have them inside the computer and make operations with it.
But, to make things easier, I ask this:
Which is one method of drawing a line that can have properties?
I will solve the other things later. Thanks in advance.
Carlos Moolina
-
Oct 6th, 2007, 09:20 PM
#2
Re: Draw a line that can have properties
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 6th, 2007, 11:58 PM
#3
Re: Draw a line that can have properties
The Line Control has many properties, but keep in mind that it has NO events associated with it. This means that if you want it's properties to respond to an event (like selecting and clicking it with the mouse) you will have to put it in a control that can respond to events.
You can put a line in Labels, Frames, PictureBoxes, etc, that do have events. If you set the Line's 'Container Properties' to transparent, with no border style, the user will think they're clicking the line, but the code will be written in the click event for the container that holds the Line. The user will never know that though.
CDRIVE
-
Oct 7th, 2007, 06:45 AM
#4
Thread Starter
Junior Member
There are problems with several lines
Yes, but what if there are 2 or more lines crossed, like an X, in that case frames or picture boxes will be one over the other, and there will be problems. Maybe there is a line control that can be use outside the developing environment a is only a line and nothing associated with it, like CAD programs Autocad, Solid Edge, etc.
Any ideas?
-
Oct 7th, 2007, 06:54 AM
#5
Re: Draw a line that can have properties
cdrive only suggested a container if you needed to have events, a line control will have properties and can be placed directly on the form, if you want several, you could use an array of the line control
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 7th, 2007, 10:56 AM
#6
Re: There are problems with several lines
 Originally Posted by principiante
Yes, but what if there are 2 or more lines crossed, like an X, in that case frames or picture boxes will be one over the other, and there will be problems. Maybe there is a line control that can be use outside the developing environment a is only a line and nothing associated with it, like CAD programs Autocad, Solid Edge, etc.
Any ideas?
Put a Frame on your Form and size it to about 1"x1". Then click the LineControl in your toolbox. Then move your mouse to the Frame and hold down the mouse while moving it. This will position the Line & assign it to the Frame instead of the Form.
Repeat this procedure to insert another Line. This will be Line2. You can move either line & form an 'X' if you wish. You can also lengthen or shorten them if you wish. Now copy and paste this code into the Declarations section of your Form.
You can also put the LineControls directly on your Form and use the Form Events to reproduce any of this code, with the exception of Top & Left properties. To move a line you must use the 'X &Y' Line properties, as it doesn't support 'Top & Left' positioning properties. This is also true if you want to move the Lines within the Frame.
As you can see, each LineControl can be addressed individually.
Code:
Private Sub Form_Click()
Cls
Frame1.Top = 1700
Frame1.Left = 100
Print "The Line.Left & Line.Top properties are in the Form1 Click Event"
End Sub
Private Sub Form_Load()
Show
Frame1.Top = 1800
Frame1.Left = 1920
Frame1.BorderStyle = 0
Frame1.Caption = ""
Print "LineControl Demo"
Print "Click on either of line."
Print "Now double click on either line"
Print "Now move the mouse"
Print "Move the mouse to Form and click it."
End Sub
Private Sub Frame1_Click()
Line1.BorderWidth = 3
End Sub
Private Sub Frame1_DblClick()
Line2.BorderWidth = 3
End Sub
Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Line1.BorderWidth = 3 And Line2.BorderWidth = 3 Then
Line1.BorderColor = &HFF&
Line2.BorderColor = &HFF&
End If
End Sub
CDRIVE
Last edited by CDRIVE; Oct 7th, 2007 at 11:01 AM.
Reason: typo
-
Oct 7th, 2007, 04:12 PM
#7
Thread Starter
Junior Member
Re: Draw a line that can have properties
Well this post was very useful. I will try to experiment with this and other I downloaded and to give it more accuracy and write later
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
|