473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using 2 instances of Line and PSet on same image?


I'm making a 'whiteboard' application.

I'm trying to have 2+ connected users able to draw at the same time.

However, if User1 draws a line, when User2 is drawing, on User1 screen,
it will draw another line, connecting User1's, and User2's current X,Y
position.
Same thing happens with User2.

But User3, and User4 is not drawing, and see the lines drawn individually.

I know the reason behind it. Although tough for me to explain.

Picture1_MouseDown uses the "Picture1.PSet (X,Y), Color"
Picture1_MouseMove uses the "Picture1.Line -(X,Y), Color"

I have tried every combinatin of Line, and PSet, none fixing my problem.

I'm sure if I used a transparent image, loaded into an Image Object,
I could assign a 'layer' to each connected user and PSet, and Line 'should'
work independantly from all other layers.

Is there -another- way around this, or am i stuck having to use the
transparent solution?


Jul 17 '05 #1
5 2706
> I'm making a 'whiteboard' application.

I'm trying to have 2+ connected users able to draw at the same time.

However, if User1 draws a line, when User2 is drawing, on User1 screen,
it will draw another line, connecting User1's, and User2's current X,Y
position.
Same thing happens with User2.

But User3, and User4 is not drawing, and see the lines drawn individually.

I know the reason behind it. Although tough for me to explain.

Picture1_MouseDown uses the "Picture1.PSet (X,Y), Color"
Picture1_MouseMove uses the "Picture1.Line -(X,Y), Color"

I have tried every combinatin of Line, and PSet, none fixing my problem.

I'm sure if I used a transparent image, loaded into an Image Object,
I could assign a 'layer' to each connected user and PSet, and Line 'should' work independantly from all other layers.

Is there -another- way around this, or am i stuck having to use the
transparent solution?


I'm not 100% sure I understand what you are trying to do, but let me guess.
I think the "structure" for a particular user (say identified as "1") should
be this

Dim LastX1 As Single
Dim LastY1 As Single
Dim Drawing1 As Boolean

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX1 = X
LastY1 = Y
Drawing1 = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX1, LastY1)-(X, Y), Color
LastX1 = X
LastY1 = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing1 = False
End Sub

That allows a user to start drawing anywhere within the PictureBox (while
the left-mousebutton is down). If you want to track other people doing
drawing, you can give them their own ID, duplicating the above for each. As
that would become cumbersome to code, I'd suggest using an array to identify
each person who is drawing. Maybe something like this (although I'm unclear
how multiple people are working in the program at one time):

Dim LastX() As Single
Dim LastY() As Single
Dim Drawing() As Boolean
Dim UserNumber As Integer

Private Sub Form_Load()
Dim NumberOfUsers
' Get the number of users by
' whatever means you are now using
NumberOfUsers = 3
ReDim LastX(1 To 3)
ReDim LastY(1 To 3)
ReDim Drawing(1 To 3)
' Elsewhere in code, identify the user
' who is drawing, again using whatever
' means you are now using
UserNumber = 2
End Sub

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX(UserNumber) = X
LastY(UserNumber) = Y
Drawing(UserNumber) = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX(UserNumber), _
LastY(UserNumber))-(X, Y), vbRed
LastX(UserNumber) = X
LastY(UserNumber) = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing(UserNumber) = False
End Sub

Hopefully, this is somewhere near the solution you are looking for.

Rick - MVP
Jul 17 '05 #2
> Private Sub Form_Load()
Dim NumberOfUsers
' Get the number of users by
' whatever means you are now using
NumberOfUsers = 3
ReDim LastX(1 To 3)
ReDim LastY(1 To 3)
ReDim Drawing(1 To 3)
' Elsewhere in code, identify the user
' who is drawing, again using whatever
' means you are now using
UserNumber = 2
End Sub


In the 2nd group of code I listed, I showed this Form_Load event. I used
that for testing purposes. The code listed in it would actually be executed
by you wherever in your program it makes sense to do so.

Rick - MVP
Jul 17 '05 #3
Yes, I know the question is not very clear.
And im not coming up w/ the right words to describe my problem

But I can get any/all users to draw.

The problem is, if User1 starts to draw a vertical line from top to
bottom of the left side of the Picture1, and User2 starts to draw
a vertical line from top to bottom on the right side of Picture1, both of
the
lines will draw fine, however, on User1, and User2 screen, horizontal lines
will appear connecting the two vertical lines at the X,Y position of User1/2

Any other users that are 'not' drawing, will see both vertical lines being
drawn fine.
No horizontal lines will be displayed.
But if they start drawing while someone else is, they will get them too.

If i wanted to draw at the same time, 2 horizontal lines down the sides of
a picture box, how would I do that? (not sure if this clears anything up or
not :c)

Do I have to 'queue' them?
Sorta Kinda Like the following...

Dim imDrawing As Boolean
Dim Color As Long
' Color gets assigned in the CommonDialog (Color) object

Private Sub Picture1_MouseDown (Button As Integer, _
Shift As Integer, X As Single, Y As Single)

imDrawing = True ' Ok, You are drawing

' stop all other drawing on your
' Picture1 Box until MouseUp.

Picture1.PSet (X,Y), Color

End Sub

Private Sub Map_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)

isDrawing = False

' We stopped drawing, so clear drawing queue
' so clear queue now

End Sub

Private Sub Winsock1_DataArrival(Index As Integer, _
ByVal bytesTotal As Long)

Dim sData As String
Winsock1(Index).GetData sData
' sData = "LINE:X ,Y, Color,DrawWidth

' insert code to pull out the fields here

If imDrawing = True Then
'
' Queue drawing requests here until MouseUp
'
Else
' We are not drawing, so go ahead and write the line
Picture1.DrawWidth = DrawWidth
Picture1.Line -(X,Y), Color
End If

End Sub
If you understand where Im going with the above...
It would still be an inconvenience, because you can't
see anyone else drawing while your drawing.
(however, id rather it be that way then no way at all)

Like I said, the unexpected lines that come up, are only seen
by the people drawing. Anyone -not- drawing see the lines as
they should be.

Confusing? Story of my life :c)

I'm not 100% sure I understand what you are trying to do, but let me guess. I think the "structure" for a particular user (say identified as "1") should be this

Dim LastX1 As Single
Dim LastY1 As Single
Dim Drawing1 As Boolean

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX1 = X
LastY1 = Y
Drawing1 = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX1, LastY1)-(X, Y), Color
LastX1 = X
LastY1 = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing1 = False
End Sub

That allows a user to start drawing anywhere within the PictureBox (while
the left-mousebutton is down). If you want to track other people doing
drawing, you can give them their own ID, duplicating the above for each. As that would become cumbersome to code, I'd suggest using an array to identify each person who is drawing. Maybe something like this (although I'm unclear how multiple people are working in the program at one time):

Dim LastX() As Single
Dim LastY() As Single
Dim Drawing() As Boolean
Dim UserNumber As Integer

Private Sub Form_Load()
Dim NumberOfUsers
' Get the number of users by
' whatever means you are now using
NumberOfUsers = 3
ReDim LastX(1 To 3)
ReDim LastY(1 To 3)
ReDim Drawing(1 To 3)
' Elsewhere in code, identify the user
' who is drawing, again using whatever
' means you are now using
UserNumber = 2
End Sub

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX(UserNumber) = X
LastY(UserNumber) = Y
Drawing(UserNumber) = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX(UserNumber), _
LastY(UserNumber))-(X, Y), vbRed
LastX(UserNumber) = X
LastY(UserNumber) = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing(UserNumber) = False
End Sub

Hopefully, this is somewhere near the solution you are looking for.

Rick - MVP

Jul 17 '05 #4
Rick's approach is right. After re-reading your original post, I realized that
the issue is where you said:

Picture1_MouseMove uses the "Picture1.Line -(X,Y), Color"

This draws a line from the "current position". Picture1 has only one current
position, even if two users are drawing, so you would be getting "cross" lines.
Something like Rick's structure, with separate LastX and LastY positions for
each user, should fix it up, without having to queue.

By the way, in a previous thread, it became pretty clear that using the
transparent property would not fix this sort of problem. Basically it seems that
you can't draw on a transparent background.

Just curious: have you checked that your network will allow your Winsock
connections? Many systems use firewalls to clamp down on which ports can be used
for connections.

"C. Alexander" <ca********@nospam.yahoo.com> wrote in message
news:u1*******************@fe3.columbus.rr.com...
Yes, I know the question is not very clear.
And im not coming up w/ the right words to describe my problem

But I can get any/all users to draw.

The problem is, if User1 starts to draw a vertical line from top to
bottom of the left side of the Picture1, and User2 starts to draw
a vertical line from top to bottom on the right side of Picture1, both of
the
lines will draw fine, however, on User1, and User2 screen, horizontal lines
will appear connecting the two vertical lines at the X,Y position of User1/2

Any other users that are 'not' drawing, will see both vertical lines being
drawn fine.
No horizontal lines will be displayed.
But if they start drawing while someone else is, they will get them too.

If i wanted to draw at the same time, 2 horizontal lines down the sides of
a picture box, how would I do that? (not sure if this clears anything up or
not :c)

Do I have to 'queue' them?
Sorta Kinda Like the following...

Dim imDrawing As Boolean
Dim Color As Long
' Color gets assigned in the CommonDialog (Color) object

Private Sub Picture1_MouseDown (Button As Integer, _
Shift As Integer, X As Single, Y As Single)

imDrawing = True ' Ok, You are drawing

' stop all other drawing on your
' Picture1 Box until MouseUp.

Picture1.PSet (X,Y), Color

End Sub

Private Sub Map_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)

isDrawing = False

' We stopped drawing, so clear drawing queue
' so clear queue now

End Sub

Private Sub Winsock1_DataArrival(Index As Integer, _
ByVal bytesTotal As Long)

Dim sData As String
Winsock1(Index).GetData sData
' sData = "LINE:X ,Y, Color,DrawWidth

' insert code to pull out the fields here

If imDrawing = True Then
'
' Queue drawing requests here until MouseUp
'
Else
' We are not drawing, so go ahead and write the line
Picture1.DrawWidth = DrawWidth
Picture1.Line -(X,Y), Color
End If

End Sub
If you understand where Im going with the above...
It would still be an inconvenience, because you can't
see anyone else drawing while your drawing.
(however, id rather it be that way then no way at all)

Like I said, the unexpected lines that come up, are only seen
by the people drawing. Anyone -not- drawing see the lines as
they should be.

Confusing? Story of my life :c)

I'm not 100% sure I understand what you are trying to do, but let me

guess.
I think the "structure" for a particular user (say identified as "1")

should
be this

Dim LastX1 As Single
Dim LastY1 As Single
Dim Drawing1 As Boolean

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX1 = X
LastY1 = Y
Drawing1 = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX1, LastY1)-(X, Y), Color
LastX1 = X
LastY1 = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing1 = False
End Sub

That allows a user to start drawing anywhere within the PictureBox (while
the left-mousebutton is down). If you want to track other people doing
drawing, you can give them their own ID, duplicating the above for each.

As
that would become cumbersome to code, I'd suggest using an array to

identify
each person who is drawing. Maybe something like this (although I'm

unclear
how multiple people are working in the program at one time):

Dim LastX() As Single
Dim LastY() As Single
Dim Drawing() As Boolean
Dim UserNumber As Integer

Private Sub Form_Load()
Dim NumberOfUsers
' Get the number of users by
' whatever means you are now using
NumberOfUsers = 3
ReDim LastX(1 To 3)
ReDim LastY(1 To 3)
ReDim Drawing(1 To 3)
' Elsewhere in code, identify the user
' who is drawing, again using whatever
' means you are now using
UserNumber = 2
End Sub

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX(UserNumber) = X
LastY(UserNumber) = Y
Drawing(UserNumber) = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX(UserNumber), _
LastY(UserNumber))-(X, Y), vbRed
LastX(UserNumber) = X
LastY(UserNumber) = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing(UserNumber) = False
End Sub

Hopefully, this is somewhere near the solution you are looking for.

Rick - MVP


Jul 17 '05 #5

I have been away so I have not been able to try out Ricks suggestion.
Will be testing tomorrow.

I have used Picture1.Line -(X,Y), Color as well as Picture1.PSet
(X,Y),Color and
Picture1.Line(X,Y)-(X,Y),Color without any hint of success.

Not sure what you are asking about winsock connections.
I haven't had any problems networking the application.

And thanks for the replies guys. I needed the help.

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:mv********************@comcast.com...
Rick's approach is right. After re-reading your original post, I realized that the issue is where you said:

Picture1_MouseMove uses the "Picture1.Line -(X,Y), Color"

This draws a line from the "current position". Picture1 has only one current position, even if two users are drawing, so you would be getting "cross" lines. Something like Rick's structure, with separate LastX and LastY positions for each user, should fix it up, without having to queue.

By the way, in a previous thread, it became pretty clear that using the
transparent property would not fix this sort of problem. Basically it seems that you can't draw on a transparent background.

Just curious: have you checked that your network will allow your Winsock
connections? Many systems use firewalls to clamp down on which ports can be used for connections.

"C. Alexander" <ca********@nospam.yahoo.com> wrote in message
news:u1*******************@fe3.columbus.rr.com...
Yes, I know the question is not very clear.
And im not coming up w/ the right words to describe my problem

But I can get any/all users to draw.

The problem is, if User1 starts to draw a vertical line from top to
bottom of the left side of the Picture1, and User2 starts to draw
a vertical line from top to bottom on the right side of Picture1, both of the
lines will draw fine, however, on User1, and User2 screen, horizontal lines will appear connecting the two vertical lines at the X,Y position of User1/2
Any other users that are 'not' drawing, will see both vertical lines being drawn fine.
No horizontal lines will be displayed.
But if they start drawing while someone else is, they will get them too.

If i wanted to draw at the same time, 2 horizontal lines down the sides of a picture box, how would I do that? (not sure if this clears anything up or not :c)

Do I have to 'queue' them?
Sorta Kinda Like the following...

Dim imDrawing As Boolean
Dim Color As Long
' Color gets assigned in the CommonDialog (Color) object

Private Sub Picture1_MouseDown (Button As Integer, _
Shift As Integer, X As Single, Y As Single)

imDrawing = True ' Ok, You are drawing

' stop all other drawing on your
' Picture1 Box until MouseUp.

Picture1.PSet (X,Y), Color

End Sub

Private Sub Map_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)

isDrawing = False

' We stopped drawing, so clear drawing queue
' so clear queue now

End Sub

Private Sub Winsock1_DataArrival(Index As Integer, _
ByVal bytesTotal As Long)

Dim sData As String
Winsock1(Index).GetData sData
' sData = "LINE:X ,Y, Color,DrawWidth

' insert code to pull out the fields here

If imDrawing = True Then
'
' Queue drawing requests here until MouseUp
'
Else
' We are not drawing, so go ahead and write the line
Picture1.DrawWidth = DrawWidth
Picture1.Line -(X,Y), Color
End If

End Sub
If you understand where Im going with the above...
It would still be an inconvenience, because you can't
see anyone else drawing while your drawing.
(however, id rather it be that way then no way at all)

Like I said, the unexpected lines that come up, are only seen
by the people drawing. Anyone -not- drawing see the lines as
they should be.

Confusing? Story of my life :c)

I'm not 100% sure I understand what you are trying to do, but let me

guess.
I think the "structure" for a particular user (say identified as "1")

should
be this

Dim LastX1 As Single
Dim LastY1 As Single
Dim Drawing1 As Boolean

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX1 = X
LastY1 = Y
Drawing1 = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX1, LastY1)-(X, Y), Color
LastX1 = X
LastY1 = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing1 = False
End Sub

That allows a user to start drawing anywhere within the PictureBox (while the left-mousebutton is down). If you want to track other people doing
drawing, you can give them their own ID, duplicating the above for
each. As
that would become cumbersome to code, I'd suggest using an array to

identify
each person who is drawing. Maybe something like this (although I'm

unclear
how multiple people are working in the program at one time):

Dim LastX() As Single
Dim LastY() As Single
Dim Drawing() As Boolean
Dim UserNumber As Integer

Private Sub Form_Load()
Dim NumberOfUsers
' Get the number of users by
' whatever means you are now using
NumberOfUsers = 3
ReDim LastX(1 To 3)
ReDim LastY(1 To 3)
ReDim Drawing(1 To 3)
' Elsewhere in code, identify the user
' who is drawing, again using whatever
' means you are now using
UserNumber = 2
End Sub

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
LastX(UserNumber) = X
LastY(UserNumber) = Y
Drawing(UserNumber) = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Drawing1 Then
Picture1.Line (LastX(UserNumber), _
LastY(UserNumber))-(X, Y), vbRed
LastX(UserNumber) = X
LastY(UserNumber) = Y
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Drawing(UserNumber) = False
End Sub

Hopefully, this is somewhere near the solution you are looking for.

Rick - MVP



Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pure Krome | last post by:
How do i serialize two instances (of some object) in the same class? I'm not sure how i would de-serialize a class that has two or more instances of some object type, and how the deserialize...
1
by: thomasb | last post by:
When setting up federation between two databases on the same instance everything works fine. When trying to do the same between two databases on different instances on the same machine I get...
6
by: Chris Tyson | last post by:
I created an Access 97 database a while ago. It is protected by Workgroup Security, and it is not split. In order to compare different sets of results, a colleague has suggested that it would be...
12
by: Aaron Prohaska | last post by:
I have been trying to figure out how to make the property values of two instances of the same control synchronize during a postback and need some help. I have posted an example of what I'm trying...
3
by: Pierre | last post by:
Hi, I am using 2 different web services: Manage_Login and Manage_Employee. In these WS I can have the same message (using the appropriate methods), and this message is an object that I...
3
by: Sandeep Singh Sekhon | last post by:
I am developing an application in ASP.NET 1.1. on one page I allow the user to upload and delete the files to the server. When I delete the file, I physically delete the file from the location....
6
by: yk | last post by:
Hi, Is it a technique available in html/javascript in order to display same image many many times on a same page? Because of a large page loading I am looking for a way not to have same...
5
by: kkirtac | last post by:
Hi, i have a class "myClass", and i want to return two instances of the same class from a function. I define an array as follows : "myClass sample ;" and i initialize two instances: "myClass...
1
by: sagarshahir | last post by:
Hi all I m using image buttons for images(thumbnails). as per my requirement i am assigning images to this image button. i want to give a pop up when this image button is clicked containin...
6
by: happyse27 | last post by:
Hi All, I have this html code below. Just like to check what is a good way to pop up an same image of its own(without new html page, but an image on top of current html page) by click on the image...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.