Re: Adding Two Picture box
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.
Re: Adding Two Picture box
most people use .zip so any chance for that? .rar i cant open and many others dont have winrar either.
1 Attachment(s)
Re: Adding Two Picture box
I upload the its .Zip file again in this post.Anyway thanks for ur information.I am not aware about this info in before.
Re: Adding Two Picture box
ill check it when i get back from work and ill see if i can see anything wrong with you code.
Re: Adding Two Picture box
ok, the first line you have
VB Code:
Dim i, j, K, m As Integer
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
End Sub
Re: Adding Two Picture box
VB Code:
Dim i, j, K, m As Integer
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..
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)
cx1 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy1 = PicArray.Item(Index).Top + PicArray.Item(Index).Height
value of m1 and m2 getting from
VB Code:
m1 = (cx1 + cx1) / 2
m2 = (cy1 + cy2) / 2
value of cx2 and cy2 getting from
VB Code:
cx2 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy2 = PicArray.Item(Index).Top
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.
Re: Adding Two Picture box
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.
Re: Adding Two Picture box
We've all been seeing the problem but not correcting it.. the basic fix is pretty easy unless I'm not understanding what the program's supposed to do.
Change this line:
VB Code:
Dim i, j, K, m As Integer
to this:
VB Code:
Dim i As Integer, j As Integer, K As Integer, m As Integer
1 Attachment(s)
Re: Adding Two Picture box
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......................
Re: Adding Two Picture box
Recalculate the lines on the event where the picture box is moved.
Re: Adding Two Picture box
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)
'Picture box moving by Mouse Move
If Line1 = True Then
X = PicArray.Item(Index).Left + X
Y = PicArray.Item(Index).Top + Y
SetLine X, Y
If FromPicture <> 0 And FromPicture <> Index Then
cx2 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy2 = PicArray.Item(Index).Top
SetLine cx2, cy2
Line1 = False
FromPicture = 0
Screen.MousePointer = vbDefault
Else
If FromPicture <> 0 And FromPicture <> Index Then
Unload MyLine.Item(Linecount - 3)
Unload MyLine.Item(Linecount - 2)
Unload MyLine.Item(Linecount - 1)
Line1 = False
End If
End If
End If
NewX = PicArray(Index).Left + X
NewY = PicArray(Index).Top + Y
If DRAGGED_SHAPE <> -1 Then
PicArray(DRAGGED_SHAPE).Left = NewX - distX
PicArray(DRAGGED_SHAPE).Top = NewY - distY
If Linecount >= 3 Then
cx1 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy1 = PicArray.Item(Index).Top + PicArray.Item(Index).Height
cx2 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy2 = PicArray.Item(Index).Top
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 If
End If
End Sub
I am facing problem now i cannot fixed the line co-ordinate during picturebox moving period with mouse event.....
Re: Adding Two Picture box
VB Code:
Private Sub PicArray_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
.........
.........
.........
[COLOR=DarkRed]cx1 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy1 = PicArray.Item(Index).Top + PicArray.Item(Index).Height
cx2 = PicArray.Item(Index).Left + PicArray.Item(Index).Width / 2
cy2 = PicArray.Item(Index).Top[/COLOR]
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???????