The VB attachment regarding for connects two Picturebox by a line connector. In this project there is two button one for adding Picture box and another one for drawing line as connector.I am facing problem to connect the two picturebox by lineconnector button. While Picture box moving the picturebox loose its connections with previous picture box. I want to join the picturebox by the lineconnector. And the pictureboxs always in connected via the line even the picturebox move by mouse move???Anyone have an idea how to slove this problem?????
Can any one help my project?????May be i didnot explain better in my post.I will better expalin if any one have specific question regarding the project..thanks in advance.
you do know that i, j, k would be variant because they are not specified as anything else right?
VB Code:
Private Sub SetLine(X As Single, Y As Single)
'Stting line Co-ordinate(Start ponit and End Point)
cx2 = X
cy2 = Y
m1 = (cx1 + cx1) / 2
m2 = (cy1 + cy2) / 2
With MyLine.Item(Linecount - 3)
.X1 = cx1
.Y1 = cy1
.X2 = m1
.Y2 = m2
End With
With MyLine.Item(Linecount - 2)
.X1 = m1
.Y1 = m2
.X2 = X
.Y2 = m2
End With
With MyLine.Item(Linecount - 1)
.X1 = X
.Y1 = m2
.X2 = X
.Y2 = Y
End With
End Sub
I am not able to make much sense of the above. youre using variables but many i cant find as having a value? for example: cx1 and cy1.
last of all
VB Code:
Private Sub Command2_Click()
'Activating connector button
blFlag = True
End Sub
youve set a boolean flag to true and youre doing nothing else. command2 is for the lineconnector commandbutton so shouldnt you call the setline sub from there?
meaning something like:
VB Code:
Private Sub Command2_Click()
'Activating connector button
blFlag = True
SetLine 'could say call SetLine, but just saying SetLine does the same thing
variant i is used for creating pcturebox array or index...I meam in every click on addpicturebox creat a new picturebox
variant j is used for moving the picturebox on form.
VB Code:
For j = i To 1 Step -1
.
k and m i dont use it at yet.I decleard it just if i may have use it later like to remove the line on using another command button.
VB Code:
Private Sub SetLine(X As Single, Y As Single)
I use the setline function coz when u r going to draw the line in this project in runtime u get there is three step in each line and each of them have three individual index which i declared as linecount.the co-ordinate of this three step is codded as
VB Code:
With MyLine.Item(Linecount - 3)(First step is for drawing a verticle line)
.X1 = cx1
.Y1 = cy1
.X2 = m1
.Y2 = m2
End With
With MyLine.Item(Linecount - 2)(2nd step drwaing a horizontal line)
.X1 = m1
.Y1 = m2
.X2 = X
.Y2 = m2
End With
With MyLine.Item(Linecount - 1)(third step drawing another last verticle line)
.X1 = X
.Y1 = m2
.X2 = X
.Y2 = Y
End With
The value of cx1 and cy1 getting from this line during mouse down period
VB Code:
Private Sub PicArray_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
I set bflag coz i have two parallel works in mouse down period.
VB Code:
Private Sub PicArray_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)If blFlag = True Then
FromPicture = Index
Screen.MousePointer = vbCrosshair
Line1 = True
......................
...............'Picture box Moving by Mouse Down
NewX = PicArray(Index).Left + X
NewY = PicArray(Index).Top + Y
Dim j As Integer
For j = i To 1 Step -1
If (PicArray(Index).Visible = True) And
So when one works is active another should be inactive.I just use bflag true or false only active the line drawing works when linconnector button click and keep the other works like moving picturebox inactive.
U can ask more regarding this,If this above info is not enough.
i want to move the line alongwith picturebox move........but in this project i am not able to do this i.e the line is keep in its positions while moving the picturebox.Simply the line would like to use just as a connector.
I update the program according to ur corrections..............In this project there is two button one for adding Picture box and another one for drawing line as connector.i just able to add picturebox and draw line on lineconnector button click. I wish the picturboxs are always in connected via the line appears on lineconnector button click.But now While Picture box moves it loose its connections with previous picture box. I want to join the picturebox by the lineconnector. And the pictureboxs always in connected via the line even the picturebox move by mouse move......................
If this is a single line with single index then its not a very difficult task it.But the main problem I use three index for drwaing a single connections coz the connector line has three steps with three individual index.....one clue i can give you...In PicArray_Mousemove we need to ensure the line co-ordinate.......
Line starting point (cx1,cy1) start from middle of the picturebox on upper side, end point(cx2,cy2) end at top middle portion of the picturebox on dow side.
I edit the code like that
VB Code:
Private Sub PicArray_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
The problem I think in mouse move period the start point of the line (cx1,cy1) and the end ponit of the line (cx2,cy2) get the same pictureindex.But i coudnot fixup the problem.It will be sloved if it is possible to declare start line ponit getting the picture index from where its start and end line point getting the picture index where it would to be end.I higlighted the portion on red color.Can any one give the idea???????